IF
ELSE STATEMENT
1.)
#include<iostream>
#include<conio.h>
using namespace
std;
int main()
{
int a;
cout<<"Enter the Number :";
cin>>a;
if(a
> 10)
cout<<a<<" Is Greater than
10";
else
cout<<a<<"
Is Less than/Equal 10";
_getch();
return
0;
}
2.)

IF ELSE IF STATEMENT
1.)
#include <iostream.h>
#include<conio.h>
#include<conio.h>
using
namespace std;
int
main(void)
{
int per;
cout
<< "Enter your Percentage::";
cin
>> per;
if
(per >=80 )
{ cout
<< "Passed with Distinction" << endl;}
else
if (per >=70 )
{ cout
<< "Passed with High Firstclass" << endl;}
else
if (per >=60 )
{ cout
<< "First Class" << endl; }
else
if (per >=50)
{ cout
<< "Second Class" << endl; }
else
{ cout << "Third Class" << endl; }
_getch();
{ cout << "Third Class" << endl; }
_getch();
return
0;
}
2.)
#include <iostream.h>
#include<conio.h>
using namespace std;
int main(void)
{
int age, height;
cin >> age;
cin >> height;
if(height == age)
cout << "Your height is equal to your age!";
else if(height < age)
cout << "Your height is less than your age!"; else if(height > age) cout << "Your height is greater than your age!"; _getch(); }
cout << "Your height is less than your age!"; else if(height > age) cout << "Your height is greater than your age!"; _getch(); }
NESTED IF ELSE STATEMENT
1.)
#include
<iostream.h>
#include<conio.h>
#include<conio.h>
using
namespace std;
int
main(void)
{
int age;
cout
<< "Enter your Age::";
cin >> age;
if
(age >=10 && age<=50)
{
if
(age >=10 && age <= 18)
{cout
<< "You are a Teenage" << endl;}
else
{ cout
<< "You not a Teenager" << endl;}
}
else
{ cout
<< "You are more than 50 years" << endl;}
_getch();
_getch();
return 0;
}
2.)
#include <iostream>
#include <cstdlib>
#include<conio.h>
using namespace std;
int main()
{
int magic;
int guess;
magic = rand(); // get a random number
cout << "Enter your guess: ";
cin >> guess;
if (guess == magic) {
cout << "** Right **\n";
cout << magic << " is the magic number.\n";
}
else {
cout << "...Sorry, you're wrong.";
if(guess > magic)
cout <<" Your guess is too high.\n";
else
cout << " Your guess is too low.\n";
}
_getch();
return 0;
}
Thanks for this blog. this helps me a lot.
ReplyDeleteA great help, indeed.
ReplyDeleteThanks for the samples. :)
ReplyDeleteVery meaningful and helpful blog. :)
ReplyDeleteThanks For this informative blog :)
ReplyDeletenice blog ! very informative :)
ReplyDeletemagagamit to sa mga assignment :)
ReplyDeleteprogramming is real hard but with the help of this blog i will be guided
ReplyDeletemalaking tulong to sa mga students :D
ReplyDeletemalaking tulong to sa mga students :D
ReplyDeleteThanks for the info :))) Mam Memeh.
ReplyDeleteThanks for the info :))) Mam Memeh.
ReplyDeleteanhirap ng programming .. thanks for this one.. keep it up girl!
ReplyDeleteMooore! hahahah.thnks for this blog!
ReplyDeletethanks for the information!!
ReplyDeleteVery helpful... thanks for the blog..
ReplyDeleteit really helps!! thank you...
ReplyDeletethank you for the examples!!
ReplyDeleteone of you examples is related to the program that i am doing..
ReplyDeletethis serves as my guide.. thanks!
Thanks for the samples ^^ this is a very helpful blog for us students
ReplyDeletesuch a good aid for my assignments.. thanks
ReplyDeletei now understand it because of this samples.. thanks!
ReplyDeletethis really helps!!
ReplyDelete