What is printed by this C code: printf(“%08.3f”, 3.14159);?
Correct answer B. 0003.142
Subject / 929 questions
Programming MCQs are multiple-choice questions on the concepts and syntax of programming languages and core computer science subjects. This hub covers C, C++, C#, Java, Python, PHP and HTML, together with DBMS and SQL, data structures, operating systems and computer networks. Many newer questions are code-output problems with explanations that show why the answer is right and why the tempting option is wrong. They suit computer science students and candidates for IT, programmer and lecturer posts.
Correct answer B. 0003.142
Correct answer A. %p
Correct answer B. It left-justifies 42 within a 6-character field
Correct answer B. %zu
Correct answer D. %lf
Correct answer D. ff 10
Correct answer D. A negative integer
Correct answer D. 42
Correct answer C. 255
Correct answer B. <ctype.h>
Correct answer D. memmove()
Correct answer C. The behaviour is undefined
Correct answer C. It modifies i twice without sequencing, which is undefined behaviour
Correct answer B. The behaviour is undefined
Correct answer A. Modifying a string literal is undefined behaviour
Correct answer D. The order is unspecified, so either may be called first
Correct answer A. 8
Correct answer A. 0 6
Correct answer A. It creates ulong as another name for the existing type unsigned long
Correct answer A. Assignment with =
The C Language section tests reserved keywords, pointers, memory allocation functions such as malloc and calloc, and loop types, including the do-while loop that runs at least once. The C++ section covers object-oriented ideas: classes as templates for objects, default access of class members, constructors and default constructors, and the header files needed for file input and output. These details are often tested through short code snippets.
The Java section covers comments, data types and the boolean results returned by relational operators, while the PHP section includes the language's history and string functions that change text case. The HTML section tests the basic structure of a web page, such as the first tag in a document, the tag for the largest heading, the image tag and the idea of block-level elements.
The computer science sections go beyond syntax. DBMS and SQL covers normalisation, keys, joins and transactions; Data Structures covers arrays, stacks, queues, linked lists, trees, graphs, hashing and complexity; Operating Systems covers processes, scheduling, deadlock, memory management and file systems; and Computer Networks covers the OSI and TCP/IP models, subnetting, routing, TCP, DNS and network security. Python and C# sections add modern language features such as list comprehensions, LINQ and async code.
Programming MCQs matter because technical posts in IT departments, teaching jobs in computer science and campus recruitment rounds use them to check fundamentals quickly. Questions often look simple but hinge on one precise rule, such as a default value or a keyword, so practising them sharpens accuracy and helps you write correct code in practical tests. It also prepares you for the written and coding stages that often follow.
Pakistan
India
Bangladesh
This category covers C, C++, C#, Java, Python, PHP and HTML, plus DBMS and SQL, Data Structures, Operating Systems and Computer Networks. Questions range from keywords and syntax to code-output problems, each with an explanation of the underlying rule.
Programming questions appear in tests for IT, programmer and computer science teaching posts. In Pakistan they appear in FPSC, PPSC and lecturer tests. In India they are common in campus placements, UGC NET and GATE, and in Bangladesh in BCS and programmer recruitment.
Yes. New code-output questions are run with a real compiler or interpreter before publishing, and the explanation walks through how the output is produced. Snippets avoid undefined behaviour unless the question is about it.
Revise core concepts language by language, then practise MCQs and test any doubtful answer by writing a small program. Pay attention to defaults, keywords and syntax details, since many questions hinge on them. Tracing code on paper also builds the speed needed for output-based questions.
A while loop checks its condition before running the body, so it may not run at all if the condition is false at the start. A do-while loop runs the body first and checks the condition afterwards, so it always executes at least once.
A constructor is a special member function that runs automatically when an object is created, usually to initialise its data. It has the same name as the class and no return type. A constructor with no parameters is called a default constructor.
Last reviewed November 2026