for Loop in C

Loops programming construct is used to execute one or more instructions repeatedly until some condition is satisfied.

The statements inside for loop gets executed until the condition become FALSE.

For loop also known as iterative statement. To iterate means to repeat. If we want to repeat 
execution of some action or statements several times, we use LOOPs.
(i)	
#include<stdio.h>
void main()
{
	int x;
	
	for(x = 0; x<5; x++)
	printf("Stephen Hawking\n");
}
(ii)
#include<stdio.h>
void main()
{
	system("color fc");
	
	int x;
	for(x = 0; x<5; x++)
	printf("Stephen Hawking\n");
}
(iii)
#include<stdio.h>
void main()
{
	int x, y;
	
	for(x = 1; y = 5; x++)
	printf("Stephen Hawking\n");
}
(iv)
#include<stdio.h>
void main()
{
	int x, y = 10;
	
	for(x = 2; y == 10; x++)
	printf("Stephen Hawking\n");
}
(v)
#include<stdio.h>
void main()
{
	int i, x, y;
	x = 2;
	y = 3;
	
	for(i = 2; x+y; i++)
	printf("Stephen Hawking\n");
}
(vi)
#include<stdio.h>
void main()
{
	int i, x, y;
	x = 2;
	y = 3;
	
	for(i = 2; (x+y)>0; i++)
	printf("Stephen Hawking\n");
}
(vii)
#include<stdio.h>
void main()
{
	int i, x, y;
	x = 2;
	y = 3;
	
	for(i = 2; (x+y)<0; i++)
	printf("Stephen Hawking\n");
}
(viii)
#include<stdio.h>
void main()
{
	int i;
	
      for(i = 2; i<=5; i++)
        {
	printf("Stephen Hawking\n");
	printf("Galaxy\n");
         }	
}
(ix)
#include<stdio.h>
void main()
{
	int i, x, y;
	
	for(i = 2; i<=5; i++)
	
	   printf("Stephen Hawking\n");
	   printf("Cosmologist\n");
	   printf("Galaxy\n");
}
(x)
#include<stdio.h>
void main()
{
	int i, x, y;
	
	for(i = 2; i<=5; i++)
	{
	   printf("Stephen Hawking\n");
	   printf("Cosmologist\n");
	   printf("Galaxy\n");
	}
}

Gopal Krishna

Hey Engineers, welcome to the award-winning blog,Engineers Tutor. I'm Gopal Krishna. a professional engineer & blogger from Andhra Pradesh, India. Notes and Video Materials for Engineering in Electronics, Communications and Computer Science subjects are added. "A blog to support Electronics, Electrical communication and computer students".

Leave a Reply

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

Translate »