Write a c++ program to display numbers which is divisible by 2 as well 3 from 6 to n by using and operator .
/*Q3) Write a c++ program to display numbers which is
divisible by 2 as well 3 from 6 to n by using
for loop and operator */
#include <iostream>
using namespace std ;
int main()
{
int i , n ;
cout<< "upto n"<<endl;
cout<<"Enter the number n (more than 6) = ";
cin>>n;
for( i= 6; i <=n ; i++)
{ if (i%2==0 && i%3==0)
{ cout<<i<<" , "; }
}
return 0;
}
output
up to n
Enter the number n (more than 6) = 45
6 , 12 , 18 , 24 , 30 , 36 , 42 , more exercise
Comments
Post a Comment
If you have any doubt ,let me know