0
Hey guys! Can someone teach me how to generate even,odd and prime numbers in flowchart? Thanks in advanceđ
4 RĂ©ponses
+ 2
use 'for' loop or 'while' loop
1. using for loop
for(int i=0; i<11; i+=2)
{
cout << "even numbers = "<< i << endl;
// shows even number
}
2. using while loop
int a=1
while(a<11)
{
cout << "Odd numbers = " << a;
a+=2;
//shows odd number
}
+ 1
//for prime num use 'for' loop
int i,a,b;
cin >> a;
for(i=2;i <a;i++){
b=a%i;
if(b==0){
cout << "Its not a prime number";
}
break;
}
if(b!=0)
{cout << "It's a prime number";}
0
@Sreejit Subhash how about prime numbers?
0
@Sreejith Thanks a lot!đ