Cetaklah bilangan ganjil dari 0-10
hasilnya ::
C++
#include <iostream>
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class bilangan{
public :
void ganjil();
private :
int i;
};
void bilangan::ganjil(){
for (i=1;i<10;i++)
if (i % 2==1)
cout<<" "<<i<<endl;
}
int main(int argc, char *argv[]) {
bilangan run;
run.ganjil();
return 0;
}
hasilnya
0 comments:
Post a Comment