To Add Two Numbers Repeatedly:
main()
{
int a, b, c; char ch;
while(1) {
printf("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)\n");
scanf(" %c",&ch);
if ( ch == 'y' || ch == 'Y' )
continue;
else
break;
}
return 0;
}
Adding Two Numbers Using Functions:
#include
Adding Two Numbers Using Functions:
#include
long addition(long, long);
main() {
long first, second, sum;
scanf("%ld%ld", &first, &second);
sum = addition(first, second);
printf("%ld\n", sum);
return 0;
}
long addition(long a, long b) {
long result;
result = a + b;
return result;
}
No comments:
Post a Comment