Friday, July 2, 2010

What is Loop in C++

,
Loop is a block code which is very useful in C or Cplusplus Programming. In real life many times we need some work in a repeated way. C and Cplusplus also provide this feature in programming we can easy to create loop which is help to your program when you need some repeat work. Loops are 2 types
1. Entry Control Loop.
2.)Exit Control Loop.



Q. if we need print a name in 10 times then we have 2 option first is write the printf command in 10 times and second is use loop


In C

# Include
# include
main()
{

int i;
char name[]={"abcd"};
for (i=1;i<=10;i++)
{

printf("%s",name);
}

in C++


# Include
# include
main()
{

int i;
char name[]={"abcd"};
for (i=1;i<=10;i++)


cout<



}

We can also write through Do while and While loop

Do While Loop

Do
{

statement

}

While Loop


main()

{

i=0;
while i<=10
{

statement

i++

}
}

0 comments to “What is Loop in C++”

Post a Comment