how do i write a value of a float to standard output?
I thought it'd be the same as putting an int which would be
Code:
printf ( "%d\n", fraction );
but apparently not =/
and is it written the same way for double?
also this question.....
Write a complete program that
declares an integer variable,
reads a value from the keyboard into that variable, and
writes to standard output the square of the variable's value.
this is waht i wrote
Code:
#include <stdio.h>
int main ()
{
int x ; {
scanf ( "%d\n", &x);
x = x* x;
printf ( "%d\n", x);
}
getchar ();
}
that part, the TA added it for me but the thing is, he doesnt speak english, so he couldnt explain what that is...
is that how you get square of something? (looks like x = x times x which would square it)
and there is this question...
writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces.
the square is x = x* x but how would i times it by two?
i wrote
but apparently its wrong.... and what does it mean separated by space ? put everything in 1 line?