C Program To Add Two Numbers
♣ Try it Out ::
#include<stdio.h> #include<conio.h> int main() { // code to add two integers int a, b, sum1; printf("\nEnter two Integers: "); scanf("%d %d", &a, &b); sum1 = a + b; printf("sum1 is: %d + %d = %d\n", a, b, sum1); // code to add two floating numbers float c, d, sum2; printf("\nEnter two Floating numbers: "); scanf("%f %f", &c, &d); sum2 = c + d; printf("sum2 is: %.2f + %.2f = %.2f\n", c, d, sum2); getch(); return(0); }
♣ Output ::
Enter two Integers: 5 6 Sum1 is: 5 + 6 = 11 Enter two Floating numbers: 5 .5 Sum2 is: 5.00 + 0.50 = 5.50
♣ Downloads ::
Comments
Post a Comment