Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;
}

(1) Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. (Submit for 2 points) Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy (2) Extend to also output in reverse. (Submit for 2 points, so 4 points total) Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy Howdy z 3.77 99 (3) Extend to cast the double to an integer, and output that integer. (Submit for 2 points, so 6 points total) Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy Howdy z 3.77 99 3.77 cast to an integer is3 Remaining 4 points will be given if meaningful variable names were used (1 point), appropriate header with your name (1 point) and appropriate formatting/style (2 points)

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

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote