C For Loop

The for loop is an entry -controlled loop which provides concise loop control structure. The for-loop statements are executed accordingly to initialization value, test expression and increment/decrement statement.

Syntax of C for Loop :-

for(initialization; test Expression; increment/decrement)

{

Body of Loop

}

Write a program to print all the natural no. till 10.

Solution :-

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=1; i<=10; i++)
{
printf(“%d”,i);
}
getch();
}

C Language for Loop

Write a program to print all the natural no.from 10 in reverse order.

Solution :-

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=10; i>=1; i--)
{
printf("%d\t",i);
}
getch();
}

C Loop for reverse order

 

 

 




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top