It's hard to see because the pictures aren't clear, but it seems like it just has you input variables and create a function to convert the variables to another one, which is called casting.
Like taking a boolean and changing it to an int or a double into a string.
int main (void) { int userInt ; double userDouble; // FIXME: Define char and string variables char userChar; //string userString; printf ( "Enter integer: \n"); scanf ("%d", &userInt); printf ( "Enter double: \n"); scanf ("%lf", &userDouble); printf ( "Enter character: \n"); scanf ("%c", &userChar); // FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space printf ("%d %lf %c \n", userInt, userDouble, userChar);
// FIXME (2): Output the four values in reverse printf ("%c %lf %d\n", userChar, userDouble, userInt);
// FIXME (3): Cast the double to an integer, and output that integer printf ("%lf cast to an integer is %lf\n", userDouble, userDouble);
Generally when homework is assigned, you're suppose to read a chapter in the book... Try it some time. I know it's crazy, but there is information in those things.
What Girls & Guys Said
Opinion
2Opinion
Seems like just assigning variables and a few functions, what part do you need help with?
Hey I'm really new at coding be honest and kind of Confuse?
It's hard to see because the pictures aren't clear, but it seems like it just has you input variables and create a function to convert the variables to another one, which is called casting.
Like taking a boolean and changing it to an int or a double into a string.
Yes it variables, input, and casting
I know what it is... what part do you need help with?
I just try it everything came out wrong
int main (void) {
int userInt ;
double userDouble;
// FIXME: Define char and string variables
char userChar;
//string userString;
printf ( "Enter integer: \n");
scanf ("%d", &userInt);
printf ( "Enter double: \n");
scanf ("%lf", &userDouble);
printf ( "Enter character: \n");
scanf ("%c", &userChar);
// FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space
printf ("%d %lf %c \n", userInt, userDouble, userChar);
// FIXME (2): Output the four values in reverse
printf ("%c %lf %d\n", userChar, userDouble, userInt);
// FIXME (3): Cast the double to an integer, and output that integer
printf ("%lf cast to an integer is %lf\n", userDouble, userDouble);
return 0;
}
int main () {
int userInt;
double userDouble;
char userChar;
char userString[20];
// Input integer from user
printf ("Enter integer:\n");
scanf ("%d", &userInt);
// Input double from user
printf ("Enter double:\n");
scanf ("%lf", &userDouble);
// Input character from user
printf ("Enter character:\n");
scanf (" %c", &userChar);
// Input string from user
printf ("Enter string:\n");
scanf (" %19[^\n]", userString);
// Print values together
printf ("%d %.2lf %c %s\n", userInt, userDouble, userChar, userString);
// Print values reversed
printf ("%s\n %c %.2lf %d", userString, userChar, userDouble, userInt);
return 0;
}
I don't know C very well, more of a Java person... but this should work well enough?
Thank you
It still came out wrong
you asking someone to pass your C exam for you? :/ You don't remember anything about printf and scanf... Kids these days...
Not exam it homework plus Never did coding before
Generally when homework is assigned, you're suppose to read a chapter in the book... Try it some time. I know it's crazy, but there is information in those things.