Thursday, December 31, 2020

Sum of all numbers between 100 and 200 using do while loop

C Program to find sum of all numbers between 100 and 200 using do while loop.

Expected output is sum of 100 + 101 + 102 + .. + 199 + 200.


Program Code

#include<stdio.h>
int main()
{
  int number=100, sum=0;
  
  do{
    sum = sum + number;
    number = number + 1;
  }while(number<=200);

  printf("Sum of all numbers between 100 to 200:"); 
  printf(" %d", sum);

  return 0;
}

Output of the program

Sum of all numbers between 100 to 200: 15150 

* * * * *


< Back to Looping Page >

< Back to Home >


No comments:

Post a Comment