Loops in c programming is a very exciting concept where we can write a repetetive code very easily
FOR LOOP:
#include<stdio.h>
int main()
{
int a;
for(a = 0 ; a < 5 ; a++)
{
printf("hello world");
}
return 0;
}
WHILE LOOP:
#include<stdio.h>
int main()
{
int a;
while(a < 5)
{
printf("hello world");
a++;
}
return 0;
}
FOR LOOP:
#include<stdio.h>
int main()
{
int a;
for(a = 0 ; a < 5 ; a++)
{
printf("hello world");
}
return 0;
}
WHILE LOOP:
#include<stdio.h>
int main()
{
int a;
while(a < 5)
{
printf("hello world");
a++;
}
return 0;
}
DO WHILE LOOP:
#include<stdio.h>
int main()
{
int a;
do
{
printf("hello world");
}
while( a < 5 );
return 0;
}
int main()
{
int a;
do
{
printf("hello world");
}
while( a < 5 );
return 0;
}
0 comments:
Post a Comment