Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include int number1; int number2; int number3; int maximum(int x, int y, int z) { int max = x; if (y > max) { max
-
#include
int number1;
int number2;
int number3;
int maximum(int x, int y, int z)
{
int max = x;
if (y > max)
{
max = y;
}
if (z > max)
{
max = z;
}
return max;
}
int main(void)
{
//int maximum(int x, int y, int z);
printf("Enter three integers: ");
scanf("%d%d%d", &number1, &number2, &number3);
printf("Maximum is: %d ", maximum(number1, number2, number3));
}
- Look for the scanf function that you have inside your main function. Modify this so instead of reading %d%d%d reads %i%i%i like this: scanf("%i%i%i", &number1, &number2, &number3);. Save these changes, compile it and run it. Make sure to enter positive and negative numbers. What happens?
- Now change this %i%i%i to %f%f%f like this: scanf("%f%f%f", &number1, &number2, &number3);. Save these changes, compile it and run it. Make sure to enter positive, negative and even decimal numbers. What happens?
- What does %d mean inside scanf?
- What does %i mean inside scanf?
- What does %f mean inside scanf?
- Now change all the integers (int) in your program for float
Save it, compile it and run it. Make sure to enter positive, negative and decimal numbers. What happens?
- Explain what happened when you changed int for float.
will upvote. thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started