To display sum of first n numbers using while loop #c
//The Program By Tittu Varghese // To display the sum of first n numbers. #include<stdio.h> #include<math.h> #include<conio.h> void main() {int i,n,s; i = 0; s = 0; printf("Enter the value of n to find sum of n numbers\n"); scanf("%d",&n); while (i <= n) {s = s+i; i = i+1; } printf("The sum of first %d numbers is %d\n",n,s); getch(); } //The Program By Tittu Varghese // To display the sum of first n even numbers. #include<stdio.h> #include<math.h> #include<conio.h> void main() {int i,n,s; i = 2; s = 0; printf("Enter the value of n to find sum of n even numbers\n"); scanf("%d",&n); while (i <= n+n) {s = s+i; i = i+2; } printf("The sum of first %d even numbers is %3d\n",n,s); getch(); } //The Program By Tittu Varghese // To display the sum of first n odd numbers. #include<stdio.h> #include<math.h> #include<conio.h...