Login
Your Email
Pasword
Home
Write
Trending
History
Liked
Dashboard

Looping in #C : while loops and their uses in programs (module 21)

In this section we will learn on the topic and concepts of loops, it's uses in programs. Types of loops, while loops, do-while loops, for loops etc

Do you have similar website/ Product?
Show in this page just for only $2 (for a month)
Create an Ad
0/60
0/180
This is the 21st module on learning C with us. Earlier we discussed on the basic introduction and structure of C, preprocessor it's features, intermediate and executable codes. compilation and execution process of a C program. And keywords and identifiers, data types, variables and constants, scope of variables, operators and expressions in C. Type casting in #C. Introduction to input and output functions and reading a character in #C. Unformatted and formatted input functions. Branching statements like if, if-else, nested if-else.
In this section we will learn on the topic and concepts of loops, it's uses in programs. Types of loops, while loops, do-while loops, for loops etc.
Looping :-
Sometimes we require a set of statements to be executed repeatedly until a condition is met.
we have two types of looping structures. One in which condition is tested before entering the statement block called as entry controlled loop.
The other in which condition is checked at exist called exit controlled loop.
While loops :-

format :
while(condition)
{ body of the loop }
It is an entry controlled loop. The condition is evaluated and if it is true then body of loop executed. After execution of body the condition is once again evaluated and if true body is executed once again. This goes on until test condition becomes false.

Example :
int main()
  { int i,result=0,n;
   printf("enter the number :\t");
  scanf("%d",&n);
  while (n!=0)
  { result=result*10+(n%10);
     n/=10;}
  printf("%d is the reverse\n",result);
  getch();
  return 0;
  }
In next module we will continue our discussions on the next topic on loops like do-while and for. For more information regarding #C please be updated with us only on Www.newsandstory.com as we provide all the information on all the topics covered in #C.
CONTINUE READING
loops
control statement
while
do-while
for
entry control
exit control
programming
learning
coding
technology
Dalpat I
Content writer