As sometimes in a program we need to print same thing over and over or like ten times for example we can make a program that will a line ten times with the help of FOR LOOP.
C Program:-
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int num;
for(num=1;num<=10;num++)
{
printf("\n This is a C language program") ;
}
getch();
}
Output:-
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
NOTE:-
As you can see in this program in the for loop "num=1" is the starting value and "num<=10" is the ending value and "num++" means the increment of 1 as in recent posts i have explained you the increment and decrements operators in C and C++ programming language.
C Program:-
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int num;
for(num=1;num<=10;num++)
{
printf("\n This is a C language program") ;
}
getch();
}
Output:-
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
This is a C language program
NOTE:-
As you can see in this program in the for loop "num=1" is the starting value and "num<=10" is the ending value and "num++" means the increment of 1 as in recent posts i have explained you the increment and decrements operators in C and C++ programming language.
No comments:
Post a Comment