-In C programming language, c provides if statement to take one way decision.
-If the condition is true than it will execute the statement(s) otherwise it will not execute the statement(s).
Syntax:
if(condition)
statement(s);
-Simple if statement provides only one way decision.
-If the statements are more than one than it will be written in { and } braces.
Example:
#include<conio.h>
#include<stdio.h>
void main()
{
float per;
clrscr();
printf("enter the percentage:");
scanf("%f",&per);
if(per>=35)
printf("Congratulations!!");
getch();
}
OUTPUT:
enter the percentage: 40
Congratulations!!
-If the condition is true than it will execute the statement(s) otherwise it will not execute the statement(s).
Syntax:
-If the statements are more than one than it will be written in { and } braces.
Example:
#include<conio.h>
#include<stdio.h>
void main()
{
float per;
clrscr();
printf("enter the percentage:");
scanf("%f",&per);
if(per>=35)
printf("Congratulations!!");
getch();
}
OUTPUT:
enter the percentage: 40
Congratulations!!
RELATED TOPICS |
---|
if...else statement. |
if...else if ladder(multiple if else). |
Switch...case Statement in C programming language. |
thanks for this code, this is most important concepts in c language......again thanks.
ReplyDelete