C++ Program that Display Series of number from 0 to Limit enter by a user and if a number is divisible by 2 then the program print I'm divisible by else I'm not divisible by 2
#include <iostream>
using namespace std;
int main()
{
int a=0,limit;
cout<<"Enter the limit : " ;
cin>>limit;
while(a<=limit){
if(a%2==0){
cout<<a<<" I'm divisible by 2 "<<endl;
}else
if(a%2!=0){
cout<<a<< " I'm not divisible by 2 "<<endl;
}
a++;
}
return 0;
}
No comments:
Post a Comment