Sunday, December 18, 2011

Sum until zero is pressed

/* A program to numbers until zero is entered. Sum the number and display */
#include <stdio.h>
int main()

{
    int i, sum=0;
    printf("enter number\n");
    scanf("%d",&i);
    while(i!=0)
    {
        sum=sum+i;
        scanf("%d",&i);
    }
    printf("sum is %d",sum);
    return 0;

}

No comments:

Post a Comment