Skip to main content
To Get All Information of Sarkari Jobs | Results | Admit Card | And courses ,Internships then CLICK HERE

While Loop-:


While loop is a condition control loop.The while loop is used to carry out looping operation.In while loop,a statement or a group of statements is/are executed repetitively until some condition has been satisfied.There must be at least one such statement within the body of loop which changes the looping condition during the execution of loop,otherwise an infinite loop may occur.While loop is also called "Entry-Control Loop"because in while loop first the condition is checked and then the statement  get executed.
ads
Syntax-:
while(condition)
    statement;
or,
while(condition)
{statement-1;
 statement-2;
 -
 -
 statement-n;
}
Example-: 
            ads
Write a program to find sum of series of terms: 1+3+5+ - - -n.
#include<stdio.h>
#include<conio.h>
main()
{ int term=0,i=1,s=0;
   printf("Enter the number of term");
   scanf("%d ",&term);
    while(i<=term)
   {s=s+(2*i-1);
          i++;
    }
   printf("\n sum=%d",s);
   getch();
}
Output-:Enter the number of term 2
               sum=4
ads Watch The Video Below

Comments

Post a Comment

Please do not enter any spam link in the comment box.


Download The Book "Let Us C" By Yashavant P.Kanetkar,Click The Below Button

-->Email Subscription

Enter Your Email Address:-

Delivered by FeedBurner

Copyright © 2020 TechProgramiz|All Right Reserved|Made By-: Sudarshan Pandey