Which among the following is the odd one out?
- printf
- fprintf
- putchar
- scanf
For a typical program, the input is taken using _________
- scanf
- Files
- Command-line
- All of the mentioned
What does the following command line signify?
prog1|prog2
- It runs prog1 first, prog2 second
- It runs prog2 first, prog1 second
- It runs both the programs, pipes output of prog1 to input of prog2
- It runs both the programs, pipes output of prog2 to input of prog1
What is the default return-type of getchar()?
- char
- int
- char *
- reading character doesn’t require a return-type
What is the value of EOF?
- -1
- 0
- 1
- 10
What is the use of getchar()?
- The next input character each time it is called
- EOF when it encounters end of file
- The next input character each time it is called EOF when it encounters end of file
- None of the mentioned
Which of the following statement is true?
- The symbolic constant EOF is defined in
- The value is -1
- The symbolic constant EOF is defined in & value is -1
- Only value is -1
What is the return value of putchar()?
- The character written
- EOF if an error occurs
- Nothing
- Both character written & EOF if an error occurs
Which is true about function tolower?
- The function tolower is defined in
- Converts an uppercase letter to lowercase
- Returns other characters untouched
- None of the mentioned
What will be the output of the following C code?
#include
int main()
{
char c = '�';
putchar(c);
}
- Compile time error
- Nothing
- 0
- Undefined behaviour
putchar(c) function/macro always outputs character c to the __________
- screen
- standard output
- depends on the compiler
- depends on the standard
What will be the output of the following C code if following commands are used to run (considering myfile exists)?
gcc -otest test.c
./test < myfile
#include
int main()
{
char c = 'd';
putchar(c);
}
- Compile time error (after first command)
- d in the myfile file
- d on the screen
- Undefined behaviour
What will be the output of the following C code if following commands are used to run (considering myfile exists)?
gcc -otest test.c
./test > myfile
#include
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
- d 2 in myfile
- d 1 in myfile
- d in myfile and 1 in screen
- d in myfile and 2 in screen
What will be the output of the following C code if following commands are used to run and if myfile does not exist?
gcc -o test test.c
./test > myfile
#include
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
- d 2 in myfile
- d 1 in myfile
- Depends on the system
- Depends on the standard
The statement prog < infile causes _________
- prog to read characters from infile
- prog to write characters to infile
- infile to read characters from prog instead
- nothing
What will be the output of the following C code?
#include
int main()
{
int i = 10, j = 2;
printf("%d\n", printf("%d %d ", i, j));
}
- Compile time error
- 10 2 4
- 10 2 2
- 10 2 5
What will be the output of the following C code?
#include
int main()
{
int i = 10, j = 3;
printf("%d %d %d", i, j);
}
- Compile time error
- 10 3
- 10 3 some garbage value
- Undefined behaviour
What will be the output of the following C code?
#include
int main()
{
int i = 10, j = 3, k = 3;
printf("%d %d ", i, j, k);
}
- Compile time error
- 10 3 3
- 10 3
- 10 3 somegarbage value
What will be the output of the following C code?
#include
int main()
{
char *s = "myworld";
int i = 9;
printf("%*s", i, s);
}
- myworld
- myworld(note: spaces to the left of myworld)
- myworld (note:followed by two spaces after myworld)
- Undefined
What will be the output of the following C code?
#include
int main(int argc, char** argv)
{
char *s = "myworld";
int i = 3;
printf("%10.*s", i, s);
}
- myw(note:7 spaces before myw)
- myworld(note:2 spaces before myworld)
- myworld (note:2 spaces after myworld)
- myw(note:6 spaces after myw)
What is the difference between %e and %g?
- %e output formatting depends on the argument and %g always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional
- %e always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional and output formatting depends on the argument
- No differences
- Depends on the standard
Escape sequences are prefixed with ________
- %
- /
- ”
- None of the mentioned
What is the purpose of sprintf?
- It prints the data into stdout
- It writes the formatted data into a string
- It writes the formatted data into a file
- None of the mentioned
he syntax to print a % using printf statement can be done by ________
- %
- \%
- ‘%’
- %%