4.2

Pertanyaan :
Cetaklah bilangan ganjil dari 0 sampai 10
Ide :
Bilangan ganjil dari 0 sampai 10 diawali dengan 1, kemudian bertambah dengan 2 atau bilangan ganjil adalah bilangan yang bila dibagi 2 bersisa 1.
contoh : 1,3,5,7,9

Jawaban :

#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int  x;
x=0;
while(!(x>10)){
if(x%2==0){

}
else{
cout<<x<<endl;
}x=x+1;
}
return 0;
}

Raptor :

Share on Google Plus

About Luthfi

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment