Counter Control Loop in C language

 Counter Control Loop 

💥Counter Control Loop :- Counter Control Loop are those loops which perform a particular task for a specific number of time. When we know in advance that how many number of tasks our loop should reapete a task again and again, for that we use counter control loop.

'for' loop is counter control loop . It perform a specific task for a specific number of time .

syntex for Counter Control Loop :-

for(initialization ; counter condition ;  updation)

{

// set of statements;

}

👉 In for lop 1st of all initialization is done  after that condition is evaluated. If conition is true then statement or set of statements are executed after that updation is done . Again condition is evaluated , if conition is true then statement or set of statements are executed after that updation is done and it  will be continue for a specific number of time.

Example:- 

program to  print my name sonu kumar , 5 times using for loop.

#include<stdio.h>   

#include<conio.h>

main()

{

int a;

clrscr();

for(a=1;a<=5;a++)

{

printf("my name is sonu kumar\n");

}

getch();

}

Output:-

my name is sonu kumar  

my name is sonu kumar

my name is sonu kumar

my name is sonu kumar

my name is sonu kumar

 Thank You for reading......

Read more about c : https://khoobstudy.blogspot.com/


No comments

Powered by Blogger.