Retrieving academic index assets...
Makaut
HomePYQsTests
Pricing
Sign Up
Makaut

The premier academic archive for MAKAUT students, providing curated previous year questions, solutions, and official syllabus resources.

Get the Mobile App
GET IT ONGoogle Play
Download on theApp Store
Download from Indus App Store
Platform
  • Home
  • PYQs
  • Question Papers
  • Viva Questions
  • Important Questions
  • Syllabus
  • Academic Tools
  • Pricing
  • Blog
Guidelines
  • Disclaimer
  • Community Guidelines
Company
  • About
  • Contact
  • FAQ
Legal
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Cookie Policy
  • Subscription Policy
© 2026 MAKAUT Study Dev Hub. All rights reserved.
Platform version: v1.0.0
Viva Questions/ES-CS201
Semester 2ES-CS201

Programming for Problem Solving (ES-CS201) Viva Questions and Answers

36 Questions•8 min read
Prepared from MAKAUT past-year question papers.
Practice Mode:All answers visible
Jump to Topic
Operating System Basics (1)Computer Components (1)Control Statements (2)Operators and Expressions (1)Preprocessor Macros (1)Operators (1)Loops (2)Arrays (2)File Handling (1)Algorithms (2)Programming Languages (1)Computer Organization (1)Functions (3)Pointers and Functions (1)Dynamic Memory (2)Structures and Unions (1)Recursion (1)Language Translators (1)Number Systems (2)Strings (2)Loops and Patterns (1)Structures (1)Command Line Arguments (1)Data Types (2)Declarations (1)Preprocessor (1)

Operating System Basics

1 question
Q1.EASY

What is an operating system and what are its main functions?

An operating system is system software that manages computer hardware and provides services to programs. Its main functions include process management, memory management, file system management, device management, and providing a user interface.

Computer Components

1 question
Q2.EASY

What does the ALU do in a computer?

The Arithmetic Logic Unit performs arithmetic operations like addition and subtraction, and logical operations like AND, OR, and comparison. It is a key part of the CPU.

Control Statements

2 questions
Q3.MEDIUM

What is the output of this code? for (i=1;i<=5;i++) { if (i%2) continue; printf ("%d", i); }

The loop prints only even numbers because continue skips odd iterations. So the output is 24.
Q32.EASY

Which one is the right output? int x = 9; if (10) printf("%d", ++x); else printf("%d", x++);

In C, any non-zero value is true, so if(10) is true. ++x pre-increments x to 10, so output is 10.

Operators and Expressions

1 question
Q4.HARD

What is the output of int i=5; printf ("%d %d", i, i++, ++i);?

This is undefined behavior in C due to multiple modifications of i without sequence points. The output is unpredictable and depends on the compiler.

Preprocessor Macros

1 question
Q5.MEDIUM

What is the output of #define SQ(x) x*x void main( ) { int a,b; a=5; b=SQ(a+2); printf("%d", b); }?

The macro expands to a+2*a+2, which is 5+2*5+2 = 17. So the output is 17, not 49, because of missing parentheses.

Operators

1 question
Q6.EASY

Which one of the following is a Bitwise operator?

Bitwise operators include &, |, ^, ~, <<, and >>. For example, & is bitwise AND.

Loops

2 questions
Q7.EASY

What is the output of fact=1; for (i=1;i<5;i++) fact=fact*i; printf("%d", fact);?

The loop multiplies fact by i from 1 to 4, so fact becomes 1*2*3*4 = 24. The output is 24.
Q28.EASY

Write down the differences between while and do-while.

while checks the condition before executing the loop body, so it may run zero times. do-while executes the body at least once before checking the condition.

Arrays

2 questions
Q8.MEDIUM

What is the output of void main( ) { int arr[6]={20, 25}; printf ("%d %d %d", arr[2], arr[3], arr[4]); }?

In C, uninitialized array elements are set to zero. So arr[2], arr[3], and arr[4] are all 0. The output is 0 0 0.
Q22.MEDIUM

Write a C program to find the largest and smallest among a list of n numbers taken as input.

Read n, then read n numbers into an array. Initialize max and min to the first element, then loop through the array updating max and min. Print max and min.

File Handling

1 question
Q9.EASY

What is the purpose of mode r+ in file handling?

Mode r+ opens a file for both reading and writing. The file must exist; otherwise, it returns NULL.

Algorithms

2 questions
Q10.EASY

What are the basic features of an algorithm?

An algorithm must be finite, definite, have zero or more inputs, produce one or more outputs, and be effective. These features ensure it solves a problem unambiguously.
Q11.MEDIUM

Write an algorithm to find the largest among three numbers taken as input.

Read a, b, c. If a >= b and a >= c, largest = a; else if b >= c, largest = b; else largest = c. Print largest.

Programming Languages

1 question
Q12.EASY

What are the disadvantages of machine language?

Machine language is difficult for humans to read and write, machine-dependent, and error-prone. It requires detailed knowledge of hardware.

Computer Organization

1 question
Q13.MEDIUM

With a suitable block diagram, briefly explain the major components and their functions of any conventional computer system.

A conventional computer has CPU (ALU and control unit), memory, input devices, and output devices. The CPU executes instructions, memory stores data and programs, and I/O devices interact with the user.

Functions

3 questions
Q14.EASY

Write a function power (a,b) to calculate the value of a raised to b.

Use a loop: result = 1; for i = 1 to b: result *= a; return result. For example, power(2,3) returns 8.
Q25.MEDIUM

Explain call by value and call by reference mechanism for passing arguments into a function. Write a C function to swap the values of two integers.

Call by value passes copies, so original values are not changed. Call by reference passes addresses, so changes affect originals. Swap function: void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }
Q30.MEDIUM

What is the difference between iterative function and recursive function?

An iterative function uses loops to repeat code, using less memory. A recursive function calls itself, using more memory due to stack, but can be simpler for problems like factorial.

Pointers and Functions

1 question
Q15.MEDIUM

What will be the output? void fun(int*, int*); main( ) { int i=5, j=2; fun(&i,&j); printf ("\n%d %d", i, j); } fun (int*i, int*j) { *i=*i**i; *j=*j**j; }

The function modifies the values through pointers: i becomes 5*5=25, j becomes 2*2=4. The output is 25 4.

Dynamic Memory

2 questions
Q16.EASY

What is dynamic memory allocation?

Dynamic memory allocation allocates memory at runtime using functions like malloc, calloc, realloc, and free. It allows flexible memory use when the size is not known at compile time.
Q17.MEDIUM

Write down the differences between malloc() and calloc().

malloc() takes one argument (size in bytes) and returns uninitialized memory. calloc() takes two arguments (number of elements and size) and initializes memory to zero.

Structures and Unions

1 question
Q18.MEDIUM

Write down the differences between structure and union.

A structure allocates separate memory for each member, so size is sum of member sizes. A union shares memory among members, so size is the largest member size, and only one member can be used at a time.

Recursion

1 question
Q19.EASY

Write a recursive C function to calculate factorial of a number.

int fact(int n) { if (n == 0 || n == 1) return 1; else return n * fact(n-1); } For example, fact(5) returns 120.

Language Translators

1 question
Q20.EASY

Write down the differences between compiler and interpreter.

A compiler translates the entire program into machine code at once and reports errors after compilation. An interpreter translates and executes line by line, reporting errors as it goes.

Number Systems

2 questions
Q21.MEDIUM

Perform the following operations: (i) Convert (100110101)₂ to octal (ii) Convert (536)₈ to hexadecimal (iii) Convert (23.78)₁₀ to binary

(i) Group bits in threes: 100 110 101 = 465₈. (ii) 536₈ = 5*64+3*8+6 = 350₁₀ = 15E₁₆. (iii) 23.78₁₀ ≈ 10111.1100011₂.
Q36.HARD

What are 2's complement numbers? How do you use this system to perform (51)₁₀ - (27)₁₀ in binary?

2's complement represents negative numbers by inverting bits and adding 1. To compute 51 - 27, find 8-bit binary of 51 (00110011) and 2's complement of 27 (11100101), add them: 00110011 + 11100101 = 00011000 (24), discard carry.

Strings

2 questions
Q23.MEDIUM

Write a C program to check whether a string taken as input is a palindrome or not.

Read a string, find its length, and compare characters from start and end moving inward. If all match, it is a palindrome; else not.
Q33.EASY

Which one is the right output? char a[50] = "computer"; printf("%d", strlen(a));

strlen returns the number of characters before the null terminator. "computer" has 8 characters, so output is 8.

Loops and Patterns

1 question
Q24.HARD

Write a C program to print the following pattern (all n rows, where n is taken as input). 1 2 3 2 3 4 5 4 3 4 5 6 7 6 5 4

Use nested loops: outer for rows, inner for spaces and numbers. For row i, print numbers from i to 2i-1 then back down to i. Adjust spacing for alignment.

Structures

1 question
Q26.MEDIUM

Define a structure called cricket that will describe the following information: Player name, team name, batting average. Using cricket, declare an array player with 5 elements and write a program to read the information about all 5 players and print a team-wise list containing names of players with their batting average.

struct cricket { char name[50]; char team[50]; float avg; }; Then declare struct cricket player[5]; read data and print grouped by team.

Command Line Arguments

1 question
Q27.MEDIUM

Write a C program that will receive a filename and a line of text as command line arguments and write the text to the file.

Use argc and argv: open file with fopen(argv[1], "w"), write argv[2] using fputs, then fclose. Check for errors.

Data Types

2 questions
Q29.EASY

What is type casting? What is automatic type conversion?

Type casting explicitly converts a value from one type to another using (type) operator. Automatic type conversion (implicit) happens when the compiler converts types automatically, like int to float in expressions.
Q35.EASY

What is the range of unsigned short int?

Typically, unsigned short int is 2 bytes (16 bits), so range is 0 to 65535.

Declarations

1 question
Q31.EASY

Which one of the following declaration is invalid?

Without options, a common invalid declaration is like int a[5] = {1,2,3,4,5,6}; (too many initializers) or missing semicolon. Generally, declarations must match type and size.

Preprocessor

1 question
Q34.MEDIUM

Which one is the right output? #define int char main() { int i = 65; printf("sizeof(i)=%d",sizeof(i)); }

The macro replaces int with char, so i is char. sizeof(char) is 1, so output is sizeof(i)=1.

Frequently Asked Viva Voce Questions

High-priority theoretical and lab evaluation questions typically tested by MAKAUT external examiners.

Related Course Resources

SYLLABUSProgramming for Problem Solving Syllabus & Handouts
Open resource
PYQSemester 2 PYQ Papers
Open resource

On This Page

26 Units
Operating System Basics1
Computer Components1
Control Statements2
Operators and Expressions1
Preprocessor Macros1
Operators1
Loops2
Arrays2
File Handling1
Algorithms2
Programming Languages1
Computer Organization1
Functions3
Pointers and Functions1
Dynamic Memory2
Structures and Unions1
Recursion1
Language Translators1
Number Systems2
Strings2
Loops and Patterns1
Structures1
Command Line Arguments1
Data Types2
Declarations1
Preprocessor1