Lecture 25
Conditional Statements (Decision Making)
Nested if Statements
Code:
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
if(getche()=='n')
if(getche()=='o')
cout
<<"\n\n You typed no. ";
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10
Code:
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
char ch;
ch=getche();
if(ch=='y')
{
cout
<<"\n\n You typed y. ";
cout <<"\n
Not some other letter. ";
}
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10