Skip to content

Instantly share code, notes, and snippets.

@anonur
Last active April 4, 2019 19:04
Show Gist options
  • Save anonur/1fed0580580fd4b2f7bc449aeedd83e4 to your computer and use it in GitHub Desktop.
Save anonur/1fed0580580fd4b2f7bc449aeedd83e4 to your computer and use it in GitHub Desktop.
Summarize integers while user enters 0
#include<stdio.h>
int main()
{
int ctr = 1;//counter
int sum = 0;//summary
while(ctr != 0) {
printf("Enter an integer: ");
scanf("%d",&ctr);
sum += ctr;//adjust xounter to summary
}
printf("\nSummary = %d",sum);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment