Infolinks - Earn Easy Money

Saturday, April 4, 2015

C++ Program to know how to use nested if

#include <iostream>
using namespace std;
int main ( )
{
int a;
cout <<" Enter a number ";
cin >> a;
if ( a%5 == 0 )
{
if ( a%3 == 0 )
{
cout <<" Number is divisible by both 3 & 5 \n";
}
else
{
cout <<" Number is divisible by 5 \n";
}
}
else
{
cout <<" Number is not divisible by 5 \n";
}
return 0;
}

No comments:

Post a Comment

Must drop your comments about post.