C Programming :: Declarations and Initializations - Discussion
35 / 54
#include<stdio.h>
void main() {
int = 12345;
float x = 145.678;
printf ("%3d, %5d, %8d", i,i,i,);
}
#include<stdio.h>
void main() {
int = 12345;
float x = 145.678;
printf ("%3d, %5d, %8d", i,i,i,);
}
A123 123 123
B123,451,234,512,346
C12345
D123
Show Explanation
assume if int i=12345;
and all syntax is right then the answer will be
12345, 12345, 12345
(check in GDB if you have any doubts)
Asked In ::
Here, we can clearly see 2 syntactical errors-
1> variable 'i' not declared.
2> There is an extra ',' used in the printf() function.
Now, consider that there were no errors in this particular code, then the output would have been-
12345, 12345, 12345
If you do not know what does %3d, %5d, %8d mean then don't worry.
Here, the number before the left of 'd' are the number of spaces in the left of the number. Basically, if the number is greater than the number of digits then we will be seeing the spaces.
Read Full Answer
Report Error
Please Login First Click Here
i not declared and in printf (,) is the extra is shows error
assume if int i=12345;
and all syntax is right then the answer will be
12345, 12345, 12345
(check in GDB if you have any doubts)
Read Full Answer
Report Error
Please Login First Click Here