Input and Output
Question 1
|
Predict the output of following program?
#include "stdio.h"int main(){ char arr[100]; printf("%d", scanf("%s", arr)); /* Suppose that input value given for above scanf is "GeeksQuiz" */ return 1;} |
9
| |
1
| |
10
| |
100
|
Discuss it
Question 2
|
Predict output of the following program
#include <stdio.h>int main(){ printf("\new_c_question\by"); printf("\rgeeksforgeeks"); getchar(); return 0;} |
ew_c_question
geeksforgeeks | |
new_c_ques
geeksforgeeks | |
geeksforgeeks | |
Depends on terminal configuration
|
Discuss it
Question 3
|
#include <stdio.h>int main() { printf(" \"GEEKS %% FOR %% GEEKS\""); getchar(); return 0; } |
“GEEKS % FOR % GEEKS”
| |
GEEKS % FOR % GEEKS
| |
\"GEEKS %% FOR %% GEEKS\"
| |
GEEKS %% FOR %% GEEKS
|
Discuss it
Question 4
|
#include <stdio.h>// Assume base address of "GeeksQuiz" to be 1000int main(){ printf(5 + "GeeksQuiz"); return 0;} |
GeeksQuiz
| |
Quiz
| |
1005
| |
Compile-time error
|
Discuss it
Question 5
|
Predict the output of the below program:
#include <stdio.h>int main(){ printf("%c ", 5["GeeksQuiz"]); return 0;} |
Compile-time error
| |
Runtime error
| |
Q
| |
s
|
Discuss it
Question 6
|
Predict the output of below program:
#include <stdio.h>int main(){ printf("%c ", "GeeksQuiz"[5]); return 0;} |
Compile-time error
| |
Runtime error
| |
Q
| |
s
|
Discuss it
Question 7
|
Which of the following is true
gets() can read a string with newline chacters but a normal scanf() with %s can not.
| |
gets() can read a string with spaces but a normal scanf() with %s can not.
| |
gets() can always replace scanf() without any additional code.
| |
None of the above
|
Discuss it
Question 8
|
Which of the following is true
gets() doesn't do any array bound testing and should not be used.
| |
fgets() should be used in place of gets() only for files, otherwise gets() is fine
| |
gets() cannot read strings with spaces
| |
None of the above
|
Discuss it
Question 9
|
What does the following C statement mean?
scanf("%4s", str); |
Read exactly 4 characters from console.
| |
Read maximum 4 characters from console.
| |
Read a string str in multiples of 4
| |
Nothing
|
Discuss it
Question 10
|
#include<stdio.h>int main(){ char *s = "Geeks Quiz"; int n = 7; printf("%.*s", n, s); return 0;} |
Geeks Quiz
| |
Nothing is printed
| |
Geeks Q
| |
Geeks Qu
|
Discuss it
Question 11
|
Predict the output of following program?
#include <stdio.h>int main(void) { int x = printf("GeeksQuiz"); printf("%d", x); return 0;} |
GeeksQuiz9
| |
GeeksQuiz10
| |
GeeksQuizGeeksQuiz
| |
GeeksQuiz1
|
Discuss it
Question 12
|
Output of following program?
#include<stdio.h>int main(){ printf("%d", printf("%d", 1234)); return 0;} |
12344
| |
12341
| |
11234
| |
41234
|
Discuss it
Question 13
|
What is the return type of getchar()?
int
| |
char
| |
unsigned char
| |
float
|
Discuss it
Question 14
|
Normally user programs are prevented from handling I/O directly by I/O instructions in them. For CPUs having explicit I/O instructions, such I/O protection is ensured by having the I/O instructions privileged. In a CPU with memory mapped I/O, there is no explicit I/O instruction. Which one of the following is true for a CPU with memory mapped I/O?
I/O protection is ensured by operating system routine (s)
| |
I/O protection is ensured by a hardware trap
| |
I/O protection is ensured during system configuration
| |
I/O protection is not possible
|
Discuss it
Question 15
|
Which of the following functions from “stdio.h” can be used in place of printf()?
fputs() with FILE stream as stdout.
| |
fprintf() with FILE stream as stdout.
| |
fwrite() with FILE stream as stdout.
| |
All of the above three - a, b and c.
| |
In “stdio.h”, there’s no other equivalent function of printf().
|






Your contents are completely awesome and share worthy. I really appreciate your efforts that you put on this. Keep sharing.
ReplyDeleteC++ Training Institute in Delhi
You have made your points in a smart way. I am impressed with how interesting you have been able to present this content. Thanks for sharing nice information.
ReplyDeleteGraphic Design Courses in South Delhi