In this article i write examples Conditional Program
Example 1 :
Conditional IF
#include <conio.h>
#include <iostream.h>
void main()
{
int x;
clrscr();
x=5;
if(x==5)
{
cout<<"FIVE";
}
else
{
cout<<"NOT FIVE";
}
getch();
}
Example 2 :
Conditional Switch Case
#include <conio.h>
#include <iostream.h>
void main()
{
int x,y,z;
clrscr();
x=1;
y=2;
cout<<"Input 1 OR 2 : ";
cin>>z;
switch ( z )
{
case b: cout<<"One";
break;
case c: cout<<"Two";
break;
default: cout<<"False";
break;
}
getch();
}
Example 1 :
Conditional IF
#include <conio.h>
#include <iostream.h>
void main()
{
int x;
clrscr();
x=5;
if(x==5)
{
cout<<"FIVE";
}
else
{
cout<<"NOT FIVE";
}
getch();
}
Example 2 :
Conditional Switch Case
#include <conio.h>
#include <iostream.h>
void main()
{
int x,y,z;
clrscr();
x=1;
y=2;
cout<<"Input 1 OR 2 : ";
cin>>z;
switch ( z )
{
case b: cout<<"One";
break;
case c: cout<<"Two";
break;
default: cout<<"False";
break;
}
getch();
}
Comments
Post a Comment