Program Menampilkan Angka Ganjil
#include<iostream.h> |
#include<conio.h> |
class ganjil{ |
private: |
int i; |
public: |
void tampil_ganjil(int n){ |
for(i=1;i<=n;i++) |
if( i % 2 != 0) |
cout << i << " "; |
} |
}; |
int main(){ |
int n; |
cout <<"masukan nilai batas n : " ; |
cin >> n; |
ganjil x; |
x.tampil_ganjil(n); |
getch(); |
return 0; |
} |
Tidak ada komentar:
Posting Komentar