Loops
While loop
While loops Info:
- The repetition of same procedure is called as while loop until the condition gets false.
- In while condition it checks statement first and at the end it go after the execution of the statement
while(condition) { // statement }
Program to print addition of 1 to N numbers
#include<stdio.h> #include<conio.h> void main() { int n,i,sum=0; printf("enter a number:") scanf("%d",&n); i=1; while(1<=n) { sum+1=i; ++i; } printf("sum=&d,",sum); }
Write a program to print addition of digit
Program to Add Two Integers #include <stdio.h> int main() { int number1, number2, sum; printf("Enter two integers: "); scanf("%d %d", &number1, &number2); // calculating sum sum = number1 + number2; printf("%d + %d = %d", number1, number2, sum); return 0; }













