Write a C program that: (a) asks the user to input two numbers, one integer x in
ID: 3619976 • Letter: W
Question
Write a C program that:(a) asks the user to input two numbers, one integer x int and one real y int.
(b) computes the following values:
– sum: sum of x int and y real
– product: product of x int and y real
– quotient: quotient obtained when x int is divided by y real
– remainder: remainder when x int is divided by 7
– expression: (x int * 2) + (y real / 7) * 8
(c) the program outputs the following:
——————————————-
x value : <x int>
y value : <y real>
sum : <sum>
product : <product>
quotient : <quotient>
remainder : <remainder>
expression : <expression>
——————————————-
where <variable> indicates the value of variable to be printed in its place.
Identify the data type required for each result (sum, product, quotient, remainder, and expression).
Declare all the variables in the initial part of function main.
Explanation / Answer
please rate - thanks #include <stdio.h>#include <conio.h>
int main()
{int x,remainder;
double y,sum,product,quotient,expression;
printf("Enter an integer: ");
scanf("%d",&x);
printf("Enter a real number: ");
scanf("%lf",&y);
sum=x+y;
printf("Sum: %f ",sum);
product=x*y;
printf("Product: %f ",product);
quotient=x/y;
printf("Quotient: %f ",quotient);
remainder=x%7;
printf("Remainder: %d ",remainder);
expression=x*2+(y/7)*8;
printf("expression: %f ",expression);
getch();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.