Mega Code Archive

 
Categories / C / Code Snippets
 

Do while loop with continue

#include <stdio.h> int main(void) { int total, x, j; total = 0; do { printf("Enter a number (0 to stop): "); scanf("%d", &x); printf("Enter the number again: "); scanf("%d", &j); if(x != j) { printf("Mismatch\n"); continue; } total = total + x; } while(x); printf("Total is %d\n", total); return 0; }