Answer to Question #260353 in C for Mr Z

Question #260353

1. Using the online compiler

• Enter the code from the file

int main(int argc, char *argv[]) {
	float f;
	int a, b, c;
	int quotient, remainder;
	
	// Obtain integer values for a and b
	printf("Enter the value for integer a: ");
	scanf("%d", &a);
	printf("Enter the value for integer b: ");
	scanf("%d", &b);
	printf("\n\n");
	
	// Integer add, subtract, multiply, divide
	c = a + b;
	printf("%d + %d = %d\n", a, b, c);
	c = a - b;
	printf("%d - %d = %d\n", a, b, c);
	c = a * b;
	printf("%d * %d = %d\n", a, b, c);
	quotient = a / b;
	remainder = a % b;
	printf("%d / %d = %d\ r %d\n\n\n", a, b, quotient, remainder);

	// Floating point division without and without typecast.
	f = a / b;
	printf("%d / %d = %f   (a and b are integers)\n", a, b, f);
	f = (float)a / b;
	printf("%f / %d = %f   (a and b are integers but with a cast as a float)\n", (float)a, b, f);
	

 Run the program. enter integer values for Enter 4 for a, and 5 for b.











1
Expert's answer
2021-11-02T14:43:07-0400

The answer to your question is provided in the image:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS