C examples for Data Type:int
Finds sum of first n integers with while loop, read the upper limit from user
#include <stdio.h> int main(void) { // w ww . j a va 2 s . c o m int count, sum; int n; printf("Enter the upper limit: "); scanf("%d", &n); count = 0; sum = 0; while (count++ < n) sum = sum + count; printf("sum = %d\n", sum); return 0; }