Pages

Tuesday, December 24, 2013

IF Statement

Write a program that tells the age is greater 60 or not 

Source Code:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
 void main ()
{
 int age, status;
printf(Enter the age:  );
scanf(%3d, &age);
status = (age > 50);
printf(Status = %d, status);
}

Result:

Case 1:
Enter the age: 45
Status = 0

Case 2:
Enter the age: 85
Status = 1

No comments:

Post a Comment