
| Turbo C - Addition using While loop |
|
#include<stdio.h> #include<conio.h> #include<math.h> /* Programmed by Harvey Losin */ /* http://www.bikoy.com/harvey */ /* webmaster@bikoy.com */ main() { int x,y,z; x=0; y=0; z=0; clrscr(); while(x!=5) { printf("Enter a number:"); scanf("%d", &x); y=y+x; z++; } printf("nThe number entered are %d",z); printf("nThe sum of all the numbers entered is %d",y); getch(); } |