C program to add two numbers repeatedly
Posted by Spider on 7:27 AM
#include<stdio.h> main() { int a, b, c; char ch; while(1) { printf("\n Enter values of a and b :\n"); scanf("%d%d",&a,&b); c = a + b; printf("a + b = %d\n", c); printf("Do you wish to add more numbers(y/n) : "); scanf(" %c",&ch); if ( ch == 'y' || ch == 'Y' ) continue; else break; } return 0; }
/*
Output :
Enter values of a and b :
5
3
a + b = 8
Do you wish to add more numbers(y/n) : y
Enter values of a and b :
2
3
a + b = 5
Do you wish to add more numbers(y/n) : n
*/
Tags
C Basics