How to Write if..else..if Statement in C Programing.

How to Write if..else..if Statement in C Programing.

Control statements allow or enable sequential flow from one instruction to the other until the required/desired output is met. A programmer would like either to repeat instruction severally or skip instructions when writing logic in C.

They are referred to as decision-making statements. This is because they make it possible to make decisions, perform tasks repeatedly or jump from one section of code to another.

In this article, we are going to discuss a for-loop control statement in C Programming. See the below diagram that illustrates how for loop works.

In for loop, initialization is executed only once. Loop checks on the expression, if an argument is true loop is executed and the expression is updated. The process continues to form a loop until when the expression becomes false then the loop is terminated.

In for loop, initialization is executed only once. Loop checks on the expression, if an argument is true loop is executed and the expression is updated. The process continues to form a loop until when the expression becomes false then the loop is terminated.

Syntax

 for(initialization statement; condition)
{
//statement
}

See a sample code below. This is an example that illustrates how to use for loop in C Programming.

#include<stdio.h>//This is a C library 
int main()
{
int i; //initialize your variable as an intager
printf("Enter number"); //This prompts you to enter the number on screen
scanf("%d", &i); //Picks the number entered and saves in a virtual memory 
for(i=0; i<10; i) //Declare a for loop arguments here.
{
printf("%d", i); //This is the body where loop is executed
++i;
}
}

Conclusion.

In this article, we have talked about for loop. This is one of the control statements is used by programmers when coming up with repetitive statements to make decisions. Please be advised that the syntax used in this guide can is applied across all languages. Check out the next control statement guide.

Leave a Reply

Your email address will not be published. Required fields are marked *

15 + 10 =