How to use for loop in C Programming

  For loop is also a type of repetition structure. This repetition structure is simpler in syntax as compared with other 2 loops because all four loop conditions can be defined in single line. Following simple program explains how to use for loop to print numbers from 1-10. [js] #include <stdio.h> int main(void){ // for loop is a type of repetition structure in C programming. In any loop you need to fulfill following 4 conditions for(int i=1; i<=10; i++){ // here in one line we defined control variable i (condition 1), //assigned initial value to control variable i (condition 2),...
forward

How to use do-while loop in C Programming

  Do-while loop is also a type of repetition structure used to repeat statement(s) for certain number of times. The major difference between while and do while loop is that in do while loop the loop termination condition is checked after the execution of loop body whereas in while loop the loop termination condition is checked before the execution of loop body. Do-while loop at least runs one time no matter if the loop termination condition is true or false. Following simple program explains how to use do-while repetition structure (also called as do-while loop) to print numbers from 1-10....
forward

How to use while loop in C Programming

  Sometimes in C program we need to repeat statements for certain number of times. So in order to repeat statements for number of times we use repetition structure in C programming. There are 3 types of repetition structures available in C programming namely while, do-while and for. Following simple program explains how to use while repetition structure (also called as while loop) to print numbers from 1-10. [js] #include <stdio.h> int main(void){ // while loop is a type of repetition structure in C programming. In any loop you need to //fulfill following 4 conditions int i; // 1st condition:...
forward