Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am stuck on this C-Programming question? Can anyone help me solve it? Try to w

ID: 3586555 • Letter: I

Question

I am stuck on this C-Programming question? Can anyone help me solve it?

Try to write a code with following features. It should get two integers from user, and divide the bigger one to smaller one. The output should be as below. You MUST use type casting for this question. Also use the print format I used in example.

a) The output should be an integer

b) The output should be an integer following by zeros after point

c) The output should be the exact result of division.

Example:

//////////////////////////////////////////////////////////////////////

Input 1: 10 ******* Input2: 3

/////////////////////////////////////////////////////////////////////

The answer for a is : 3

The answer for b is : 3.00000

The answer for c is : 3.33333

Explanation / Answer

#include <stdio.h>

int main()
{
int n1, n2;
printf("Input 1: ");
scanf("%d", &n1);
printf("Input 2: ");
scanf("%d", &n2);
printf("The answer for a is : %d ", n1/n2);
printf("The answer for b is : %lf ", (double)(n1/n2));
printf("The answer for c is : %lf ", n1/(double)n2);

return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote