logo
  • Home
  • Test & Rank
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Mining
  • Marine
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Jobs
  • Contact

C Multiple Choice Questions | MCQs | Quiz

C Programming Interview Questions and Answers
Practice C Programming questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   Variable Names - 1
•   Variable Names - 2
•   Data Types
•   Data Sizes
•   Constants - 1
•   Constants - 2
•   Declarations - 1
•   Declarations - 2
•   Arithmetic Operators - 1
•   Arithmetic Operators - 2
•   Relational Operators
•   Logical Operators
•   Type Conversions - 1
•   Type Conversions - 2
•   Increment Operators
•   Decrement Operators
•   Bitwise Operators - 1
•   Bitwise Operators - 2
•   Assigment Operators
•   Expressions
•   Conditional Expressions - 1
•   Conditional Expressions - 2
•   Operator Precedence - 1
•   Operator Precedence - 2
•   Order of Evaluation - 1
•   Order of Evaluation - 2
•   Associativity - 1
•   Associativity - 2
•   If Statements - 1
•   If Statements - 2
•   Switch Statements - 1
•   Switch Statements - 2
•   For Loops - 1
•   For Loops - 2
•   While Loops - 1
•   While Loops - 2
•   Break & Continue - 1
•   Break & Continue - 2
•   Goto & Labels - 1
•   Goto & Labels - 2
•   Functions Basics - 1
•   Function Basics - 2
•   Functions Return
•   Return Values
•   External Variables - 1
•   External Variables - 2
•   Variable Scope - 1
•   Variable Scope - 2
•   Static Variables - 1
•   Static Variables - 2
•   Register Variables - 1
•   Register Variables - 2
•   Automatic Variables - 1
•   Automatic Variables - 2
•   Preprocessor - 1
•   Preprocessor - 2
•   File Inclusion - 1
•   File Inclusion - 2
•   Macro Substitution - 1
•   Macro Substitution - 2
•   Conditional Inclusion - 1
•   Conditional Inclusion - 2
•   Pointers & Addresses - 1
•   Pointers & Addresses - 2
•   Function Arguments - 1
•   Pointers Arguments 2
•   Pointers & Arrays - 1
•   Pointers & Arrays - 2
•   Address Arithmetic - 1
•   Address Arithmetic - 2
•   Pointers/Functions - 1
•   Pointers/Functions - 2
•   Pointers to Pointers - 1
•   Pointers to Pointers - 2
•   Multidimensional Arrays - 1
•   Multidimensional Arrays - 2
•   Pointer Arrays Init - 1
•   Pointer Arrays Init - 2
•   Multi-dimensional Arrays - 1
•   Multi-dimensional Arrays - 2
•   Command Line Arguments1
•   Command Line Arguments2
•   Pointers to Functions - 1
•   Pointers to Functions - 2
•   Complicated Declarations-1
•   Complicated Declarations-2
•   Structures - 1
•   Structures - 2
•   Structures & Functions - 1
•   Structures & Functions - 2
•   Arrays of Structures - 1
•   Arrays of Structures - 2
•   Pointer to Structures - 1
•   Pointer to Structures - 2
•   Self-Referential Structures-1
•   Self-Referential Structures-2
•   Table Lookup - 1
•   Table Lookup - 2
•   Typedefs - 1
•   Typedefs - 2
•   Unions - 1
•   Unions - 2
•   Bit-fields - 1
•   Bit-fields - 2
•   Standard Input & Output - 1
•   Standard Input & Output - 2
•   Formatted Output - 1
•   Formatted Output - 2
•   Varargs - 1
•   Varargs - 2
•   Formatted Input - 1
•   Formatted Input - 1
•   File Access - 1
•   File Access - 2
•   Error Handling - 1
•   Error Handling - 2
•   Line Input & Output - 1
•   Line Input & Output - 2
•   String Operations - 1
•   String Operations - 2
•   Character Class - 1
•   Character Class - 2
•   Ungetc - 1
•   Ungetc - 2
•   Storage Management - 1
•   Storage Management - 2
•   Mathematical Functions - 1
•   Mathematical Functions - 2
•   Random Number - 1
•   Random Number - 2
•   printf - 1
•   printf - 2
•   scanf - 1
•   scanf - 2
•   File Operations - 1
•   File Operations - 2
•   Float Datatype - 1
•   Float Datatype - 2
•   Sizeof Keyword - 1
•   Sizeof Keyword - 2
•   Enums - 1
•   Enums - 2
•   Typedef
•   String Operations - 1
•   String Operations - 2
•   String Operations - 3
•   String Operations - 4
•   Character Handling - 1
•   Character Handling - 2
•   Error Handling
•   Mathematical Functions - 1
•   Mathematical Functions - 2
•   Mathematical Functions - 3
•   General Utilities - 1
•   General Utilities - 2
•   General Utilities - 3
•   General Utilities - 4
•   General Utilities - 5
•   General Utilities - 6
•   Diagnostics - 1
•   Diagnostics - 2
•   Variable Argument Lists
•   Localization
•   Non-Local Jumps - 1
•   Non-Local Jumps - 2
•   Signal Handling
•   Standard Definition
•   Date & Time Functions - 1
•   Date & Time Functions - 2
•   Date & Time Functions - 3
•   Defined Limits - 1
•   Defined Limits - 2
•   Dynamic Memory Allocation
•   Dangling Pointers - 1
•   Dangling Pointers - 2
•   Pragma
•   Stringizers
•   Preprocessor Directives - 1
•   Preprocessor Directives - 2
•   Token Concatenation
•   Inline
•   Endianness
•   Recursion
•   Signed Qualifier

Best Reference Books

C Programming Books

C Programming Tests

Certification Test
Internship Test
Job Test
All Tests
Top Rankers
Practice Test 1
Practice Test 2
Practice Test 3
Practice Test 4
Practice Test 5
Practice Test 6
Practice Test 7
Practice Test 8
Practice Test 9
Practice Test 10
Mock Test 1
Mock Test 2
Mock Test 3
Mock Test 4
Mock Test 5
Mock Test 6
Mock Test 7
Mock Test 8
Mock Test 9
Mock Test 10
« Prev Page
Next Page »

C Questions and Answers – printf – 2

Posted on February 2, 2013 by Manish

This set of C Multiple Choice Questions & Answers focuses on “printf – 2”.

1. If by mistake you specify more number of arguments, the excess arguments will ____________
a) be ignored
b) produce compile error
c) produce run-time error
d) produce logical error
View Answer

Answer: a
Explanation: The excess arguments will simply be ignored.
advertisement

2. What happens when zero flag is used with left justification?
a) data is padded with zeros
b) zero flag is ignored
c) data is padded with blank spaces
d) will give error
View Answer

Answer: b
Explanation: Zero flag is not considered when used with left justification because adding zeros after a number changes its value.

3. For floating point numbers, the precision flag specifies the number of decimal places to be printed. When no precision modifier is specified, printf() prints _______
a) six decimal positions
b) five decimal positions
c) four decimal positions
d) three decimal positions
View Answer

Answer: a
Explanation: Its format can be given as “. m”, where m specifies the number of decimal digits when no precision modifier is specified, printf prints six decimal positions.

4. What will the given code result in printf(“\n you are\”awesome \" ");?
a) compile error
b) run-time error
c) you are "awesome"
d) you are awesome
View Answer

Answer: c
Explanation: The above given code uses \”<word>\” to display the word within double inverted commas on standard output screen.

5. What will be the output for the given code printf(“\n The number is %07d”,1212);
a) The number is 0001212
b) The number is 1212
c) The number is 1212
d) The number is 1212000
View Answer

Answer: a
Explanation: 0 in the above code is Flags. The number is left-padded with zeros(0) instead of spaces.

6. What will be the output of the following code?

advertisement
char t=’N’;
printf(“\n %c \n %3c \n %5c”,t,t,t);

a)              N
          N
    N
b)    N
            N
                 N
c)  N
      N
      N
d)   N  N  N  
View Answer

Answer: b
Explanation: In the given code each argument is printed on a new line due to control character \n. Width mentioned in the above code is 1,3,5 hence the character is printed on a new line after being padded with blank spaces.

7. Select the right explanation to the given code.

printf(“%*. *f”, 5,4,5700);

a) the minimum field width has to be 4, the precision is given to be 5, and the value to be displayed is 5700
b) the minimum field width is 5, the precision is 4, and the value to be displayed is 5700
c) compile error
d) run-time error
View Answer

Answer: b
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.

8. What will be the output of the following C code?

advertisement
char str[] = &quot;Hello Nancy“;
printf(“\n %.7s”, str) ;

a) Hello Nan
b) Hello
c) Hello N
d) Hello Nancy
View Answer

Answer: c
Explanation: The output for the code must be 7 characters including white spaces.

9. What will be the output of the following C code?

char str[] =”Too Good”;
printf(“\n %7s”,str);

a) Too Good
b) Too G
c) Too Go
d) Too
View Answer

Answer: a
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.

10. What will be the output of the following C code?

printf(“\n Output: %5d \t %x \t %#x”, 234,234,234);

a) Output:234EA0xEA
b) Output:00234 EA 0xEA
c) Output:    234 EA 0xEA
d) ERROR
View Answer

Answer: c
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.

Sanfoundry Global Education & Learning Series – C Programming Language.

C Practice Resources
C Mock Tests & Certification Test | 1000 C MCQs | 1000 C Programs | 1000 C Algorithms | Best C Books | C Internship
« Prev Page - C Questions and Answers – printf – 1
» Next Page - C Questions and Answers – scanf – 1

« C Questions and Answers – printf – 1
C Questions and Answers – scanf – 1 »
advertisement

Deep Dive @ Sanfoundry:

  1. C++ Questions and Answers
  2. Java Programming Examples on File Handling
  3. Java Programming Examples on Classes
  4. C# Questions and Answers
  5. C Programming Examples on Bitwise Operations
  6. Java Programming Examples on Mathematical Functions
  7. C Questions and Answers
  8. C# Programming Examples on Conversions
  9. Simple C Programs
  10. Python Question and Answers – Built-in Functions – 1
Manish Bhojasia
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Facebook | Twitter

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
Terms
Privacy Policy
Jobs
Bangalore Training
Online Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry. All Rights Reserved.