for loop in c, for loop c programming, for loop syntax in c, for loop in c programming example, for loop example in c, for loop c programming practice
There are some situations statements are executed repeatedly until condition is false. In such cases we can use looping statements.
When implement the looping process it must be involve the following four points:
1. Initialization of counter value.
2.test for the specified condition.
3.execute the statements in the loop. (body of loop)
4.based on condition increment or decrement.
To implement looping process C language supports three looping statements.
1. for statement
2. while statement
3. do..while statement
1. for Statement:
In all looping statements, for statement is mostly used. The general syntax of for statement is:
for(initilization; condition; increment/decrement)
body of loop;
For above code output will
2. while Statement:
In all looping statements, while statement is simplest. The general syntax of while statement is:
body of loop;
increment or decrement;
3. DO..WHILE STATEMENT:
This is another loop statement, supported by C language. It is also perform the looping operations. The general syntax of do..while statement is as follows:
body of loop;
increment or decre;
When ever execute the do..while statement first initilize the value. Then execute the body of the loop. Once body is executed then check the condition. If it is true once again execute the body of loop. This process unitl condition is false. Once false the condition program out of the loop.
The main Difference between while and do..while statement is, in while, when ever condition is true,then execute the statements in the loop. where as in do..while first execute the statements in the loop, then check the condition. if it is true once again execute the loop, until condition false.
Some examples are given below to exicute by using looping statements.
1. WAP print sum of first 10 natural numbers.
2. WAP reverse of given number.
3. WAP findout the factorial of given number.
4. WAP Armstrong number or not.
c programming or C is a procedural programming language.
c programming was initially developed by Dennis Ritchie in the year 1972.
c programming was mainly developed as a system programming language to write an operating system.
The main features of C language or c programming include low-level access to memory, a simple set of keywords, and clean style, these features make C language suitable for system programmings like an operating system or compiler development.
Many later languages have borrowed syntax/features directly or indirectly from C language.
C++ is nearly a super set of C language (There are few programs that may compile in C, but not in C++).