# Thread: final exams

1. ## final exams

I'm studying for my finals.

Write a function named check() that has three arguments. The first argument should accept a integer number, second a floating-point number, the third a double-precision number. The body of the function should just display the values of the data passed to the function when it is called.

Code:
```#include <stdio.h>
int main()
{
void check (int, float, double);
int firstnum;
float secnum;
double thirdnum;

printf("Enter a number: ");
scanf("%d", &firstnum);
printf("Great! Please enter a second number: ");
scanf("%f", &secnum);
printf("You are almost done, now enter your last number: ");
scanf("%d", &thirdnum);

check (firstnum, secnum, thirdnum);

return 0;
}
void check (int x, float y, double z)

{
float maxnum;

if (x >= 0)
maxnum = x;
else if (y >= 0)
maxnum = y;
else if (z >= 0)
maxnum = z;

printf("\nThe three numbers entered is %.2d %.2f and %.2d\n", maxnum);
}```

2. scanf("%d", &thirdnum);
printf("\nThe three numbers entered is %.2d %.2f and %.2d\n", maxnum);

Check it!

3. Why even have user input if you don't need it?
Write a function named check() that has three arguments. The first argument should accept a integer number, second a floating-point number, the third a double-precision number. The body of the function should just display the values of the data passed to the function when it is called.
It's a one-liner.

The leftovers from some previous homework are not necessary.

All you're being asked is to use %d and %f with printf, more or less.

4. Originally Posted by Dave_Sinkula
Why even have user input if you don't need it?
It's a one-liner.

The leftovers from some previous homework are not necessary.

All you're being asked is to use %d and %f with printf, more or less.
I pretty much figured that, but when I pass my values, I don't get anything that makes sense, i've tried %d %f %f, still isn't giving me anything correct

5. Post your attempt.

6. Originally Posted by wonderpoop
I pretty much figured that, but when I pass my values, I don't get anything that makes sense, i've tried %d %f %f, still isn't giving me anything correct
I got it, i needed to take the maxnum out of the printf and put in firstnum, secnum, thirdnum

so actually everything above is corred, even the %d, %f, %d, just not the maxnum in my printf

7. yea because if you wanted "maxum" used three times in your printf, you would have to type it three times like...
Code:
`printf("\nThe three numbers entered is %.2d %.2f and %.2d\n", maxnum,maxnum,maxnum);`

Popular pages Recent additions