//Program for Checking Nestyed If, Else if Ladder & Conditional Statements.
//Downloaded from www.c4cprog.co.nr
#include<conio.h>
void main()
{
int y,x,w;
clrscr();
printf("\n\nEnter The Val of X :");
scanf("%d",&x);
clrscr();
printf("\nEnter Your Choice\n1.Else If Ladder\n2.Nested If\n3.Conditional Operator\n\n");
scanf("%d",&y);
switch(y)
{
case 1:
if(x<0)
printf("\ny=1");
else
if(x==0)
printf("\ny=0");
else
if(x>0)
printf("\ny=-1");
break;
case 2:
if(x!=0)
{
if(x>0)
printf("\ny=-1");
else
printf("\ny=1");
}
else
printf("\ny=0");
break;
case 3:
(x!=0)?((x<0)?(w=1):(w=-1)):(w=0);
printf("\ny=%d",w);
break;
default :
printf("\nInvalid Choice !!!\n");
break;
}
getch();
}
/*
Enter The Val Of X : 5
Enter Your Choice
1.Else If Ladder
2.Nested If
3.Conditional Operator
1
y=-1
0
y=0
3
y=-1
*/
Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]
Checking If Statements
Click Here To Download C File Of This Program
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment