MUST BE DONE IN C PROGRAM. #include <stdio.h> #include <string.h> // Supports us
ID: 3745230 • Letter: M
Question
MUST BE DONE IN C PROGRAM.
#include <stdio.h>
#include <string.h> // Supports use of "string" data type
int main(void) {
int userInt = 0;
double userDouble = 0.0;
// FIXME: Define char and string variables similarly
printf("Enter integer: ");
scanf("%d", &userInt);
printf(" ");
// FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space
// FIXME (2): Output the four values in reverse
// FIXME (3): Cast the double to an integer, and output that integer
return 0;
}
Explanation / Answer
#include <stdio.h>
#include <string.h>// Supports use of "string" data type
int main(void) {
int userInt = 0;
double userDouble = 0.0;
// FIXME: Define char and string variables similarly
char userChar;
char userString[20];
printf("Enter integer: ");
scanf("%d", &userInt);
printf(" ");
// FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space
printf("Enter double: ");
scanf("%lf", &userDouble);
printf(" ");
printf("Enter char: ");
scanf(" %c", &userChar);
printf(" ");
printf("Enter string: ");
scanf("%s", &userString);
printf(" ");
printf("%d %.2f %c %s ",userInt,userDouble,userChar,userString);
// FIXME (2): Output the four values in reverse
printf("%s %c %.2f %d ",userString,userChar,userDouble,userInt);
// FIXME (3): Cast the double to an integer, and output that integer
int casted;
casted=userDouble;
printf("%.2f cast to an integer is %d ",userDouble,casted);
return 0;
}
/*Sample Output
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.