0

take two numbers of int data type, two numbers of float data type as input and output their sum:

take two numbers of int data type, two numbers of float data type as input and output their sum: Declare variables: two of type int and two of type float. Read lines of input from stdin (according to the sequence given in the 'Input Format' section below) and initialize your variables. Use the and operator to perform the following operations: Print the sum and difference of two int variable on a new line. Print the sum and difference of two float variable rounded to one decimal place on a new line. I have done this code but getting error so can any one help https://code.sololearn.com/c5MPw1k0BhM9/?ref=app

17th Dec 2020, 6:29 PM
Madhuspriya Samantray
1 Answer
+ 3
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int a,b,sum1,diff1; float x,y,sum2,diff2; scanf("%d%d",&a, &b); sum1=a+b; diff1=a-b; printf("%d %d \n", sum1, diff1); scanf("%f %f", &x, &y); sum2=x+y; diff2=x-y; printf("%0.1f %0.1f", sum2, diff2); return 0; } This is the correct code. You forgot the semicolon in: int a,b,sum1,diff1; You had an extra " in: scanf("%d%d",&a, &b);
17th Dec 2020, 6:58 PM
Dimitris N. Kapoulas
Dimitris N. Kapoulas - avatar