I have to create a program that takes one integer (the value of the integer will be 1, 2, or 3). The program behaves differently depending on the value of the integer. If the number is 1, then get 2 integers from the user, and print the remainder of the first number divided by the second. If the number given is 2, then take a double from the user and print the double rounded up to the next integer. If the number given is 3, read an int from the user and print whether the number given is odd or even.
I have created the following code but I am having trouble with the 3 different numbers running 3 different jobs. - rounding to the next integer etc
Code:
#include <stdio.h>
int main()
{
int x, y, z;
double d;
printf("Please enter in 1, 2 or 3: ");
scanf("%d", &x);
if (x == 1)
{
printf("Please enter in 2 new integers: ");
scanf("%d%d", &x, &y);
printf("%d", x % y);
}
else if (x == 2)
{
printf("Please enter in a double with a decimal: ");
scanf("%f", &d);
printf("%f\n", d);
}
else (x == 3);
{
printf("Please enter in an integer: ");
scanf("%d", x);
}
if (x % 2 == 0)
{
printf("%d is even\n", x);
}
else if (x % 2 != 0)
{
printf("%d is odd\n", x);
}
}
return 0;
}