Wednesday, 20 November 2013

If statement

# include<iostream>
using namespace std;
void main()
{
cout<<"Enter any number";
cin>>a;
if(a==0)
cout<<"value of a is o"<<endl;

}

In this program,
we will take value from user,the value user gives is store in a(data type int)
If the user give inout o(zero),then the program says that:-
"Value of a is o".......!!
How is this possible,Actually if statement is a check which will check either value of a is zero nor not..!
If it is zero then Program says that,Valus is zero.....!
Note:-
If you want one statement to be executed with if,then no need to place braces(show in program),but if two or more statements are,then you will put braces like this:-
if(a==0)
{
cout<<"I am Junaid"<<endl;
cout<<"Value of a is o"<<endl;
}
I hope you wil got this..!
Feel free to give suggestions in comment box.......!

0 comments: