Formatted Input and Output in C
Quiz
•
Other
•
University
•
Hard
Harvinder Kaur
Used 9+ times
FREE Resource
Enhance your content in a minute
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the above code if a=123456789245?
123456789245
Compilation error
1234567892
No output
Answer explanation
Using %10d in scanf restricts input to a maximum of 10 digits.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The syntax of printf() function is printf(“control string”, variable list) ;
what is the prototype of the control string?
%[flags][.precision][width][length]specifier
%[flags][length][width][.precision]specifier
%[flags][width][.precision][length]specifier
%[flags][.precision][length][width]specifier
Answer explanation
The prototype of control string is %[flags][width][.precision][length]specifier. Each control string must begin with % sign
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What will be the output of the following C code?
char str[] =”Too Good”;
printf(“\n %7s”,str);
Too Good
Too G
Too Go
Too
Answer explanation
The complete string “Too Good” is printed. This is because if data needs more space than specified, then printf overrides the width specified by the user.
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What will be the output of the following C code?
printf(“\n Output: %5d \t %x \t %#x”, 234,234,234);
Output:
234EA0xEA
Output:
00234 EA 0xEA
Output:
234 EA 0xEA
ERROR
Answer explanation
The control character \t is used to provide gap between the words. %5d – the width of the string is set to 5, characters are printed after being padded with blank spaces.%x, %#x is additional specifiers for octal and hexadecimal values.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Select the right explanation to the given code.
printf(“%*. *f”, 5,4,5700);
the minimum field width has to be 4, the precision is given to be 5, and the value to be displayed is 5700
the minimum field width is 5, the precision is 4, and the value to be displayed is 5700
compile error
run-time error
Answer explanation
The minimum field width and precision specifiers are usually constants. They can also be provided by arguments to printf(). This is done by using * modifier as shown in the given code.
6.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What will be the output for the given code ?
printf (“\n The number is %07d”,1212);
The number is 0001212
The number is 1212
The number is 1212
The number is 1212000
Answer explanation
0 in the above code is Flags. The number is left-padded with zeros(0) instead of spaces.
7.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What happens when zero flag is used with left justification?
data is padded with zeros
zero flag is ignored
data is padded with blank spaces
will give error
Answer explanation
Zero flag is not considered when used with left justification because adding zeros after a number changes its value.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
14 questions
Music History Quiz
Quiz
•
University
15 questions
Harry Potter
Quiz
•
KG - Professional Dev...
15 questions
Personal finance 1
Quiz
•
University
10 questions
CCHU5001_Week 3_Quiz
Quiz
•
University
10 questions
IQ #3 MODULE 3 MARKETING MANAGEMENT
Quiz
•
University
10 questions
IIUMSU Quiz!
Quiz
•
University
10 questions
Global Urban Farming
Quiz
•
University
10 questions
La Vida Ambassador Series 1
Quiz
•
University
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
15 questions
4:3 Model Multiplication of Decimals by Whole Numbers
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
The Best Christmas Pageant Ever Chapters 1 & 2
Quiz
•
4th Grade
12 questions
Unit 4 Review Day
Quiz
•
3rd Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
Discover more resources for Other
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
7 questions
Different Types of Energy
Interactive video
•
4th Grade - University
20 questions
Slopes and Slope-Intercept Form
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
7 questions
Biomolecules (Updated)
Interactive video
•
11th Grade - University
20 questions
Winter/Holiday Trivia
Quiz
•
KG - University
10 questions
WINTER WIN Time - ELA - 12/9/2025
Quiz
•
KG - University
7 questions
Human Impact on Resources
Interactive video
•
4th Grade - University
