The if statement is a simple decision-making and branching statement and it is used to control the flow of the program execution. An if statement consists of a Boolean expression followed by one or more statements. The if statement is written with the if keyword, followed by a condition in parentheses, with the code to be executed in between curly brackets.
Syntax:
if( condition )
{
// body of the statements will execute if the condition is true ;
}
The code is a C program that demonstrates the use of the if statement in C. Here is an explanation of each line of the code:
//if statement #include<stdio.h> int main() { char name[10]; int age; printf("\nEnter Your Name : "); scanf("%s",name); printf("\nEnter The Age : "); scanf("%d",&age); if(age>=18) { printf("\n %s age is %d Eligible For Vote",name,age); } return 0; }To download raw file Click Here
Enter Your Name : Siva Enter The Age : 21 Siva age is 21 Eligible For Vote
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions