What is Loop

In programming, a loop is a sequence of statement that used for repeated of statement until a specific condition not reached.By the example, we can understand in an easy way without using loop

#include <stdio.h>
#include <conio.h>
void main() {
int x=10;
printf("Hi how are you");
}

Suppose that you want to print 10,20,100,1000 times then just think it’s possible but very difficult to type or copy-paste. By using loop we can print many types only two or three line of code.There are three types of loop used in c.for loop

For Loop In C

Loop used for executes for a group of statement repetition until condition not reached. First, initialize then check print statement and after increment/decrement then check a condition and again print statement.the syntax of for loop in c.

for(initilization;condition;incr/decr)
{
statement/expression;
}

A simple example of – for loop in c.Print Codeverb.com message for 5 times by using for loop.

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

Output
Codeverb.com 1
Codeverb.com 2
Codeverb.com 3
Codeverb.com 4
Codeverb.com 5

Just look here we do not repeat statement Codeverb.com but only two or three lines of code we are printing here for 5 times Codeverb.com messages.

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Contributor
Do you like Zubeen's articles?  Follow on social!
Comments to: For Loop In C Programming Language

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

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Explore Tutorials By Categories

Login

Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
  •  
    Strength indicator
  •  
  •  
    Log In | Lost Password