Now we start condition statement
the order of execution of the statement in a program can b changed this is done with the help of conditional statement . the codition statement also known as selection statemenet..If statement
es me hamm koi condition dy k check karty hai k true hai ya false
if(condition)
last me ; use nahe karna hai agr use kia to per us ka matlb ho ga k if ke body khali hai
es par ek ya 2 example karty hai to samj ajy ga
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
a=100;
b=50;
if(a>b)
cout<<”Islamabad”<<endl;
getch();
}
es me agr a bara hai b se to condition true ho ge then Islamabad show kary ga result me agr flase ho gai to nahe kary ga
#include<conio.h>
void main()
{
int n;
cout<<”enter a number”;
cin>>n; // input from user
if(n%3==0)
{
cout<<”the num”<<n<<”is divided by 3”;
getch();
}
es me ham ek input user se lain gy ur check karny gy k 3 par fully divide hoti hai yan agr true ho to result show kar dy ga other wise nahe
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
cin>>a;
cin>>b;
if(a>b)
cout<<”c++”;
if(b>a)
cout<<”java”
getch();
}
es me user se 2 input lain gy agr a greater ta b se to per c++ output me yae ga agr b greter ta to pe java
ap log khud se kuch program bana k practice if statement par kal InshAllah if else py kam karian gy
Reg:: Mt Ali Okz
No comments:
Post a Comment