0% found this document useful (0 votes)
16 views3 pages

C Programming Important Questions 2021-2024

The document outlines important and repeated questions for the Programming for Problem Solving course (BSC-104-G) from 2021 to 2024, categorized by units covering C programming basics, control structures, arrays and functions, and structures, pointers, and file handling. Each unit includes questions of varying marks, detailing topics such as data types, control structures, arrays, and file handling functions, along with specific programming tasks. The document serves as a study guide for students preparing for exams in this subject.

Uploaded by

Gaming King
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

C Programming Important Questions 2021-2024

The document outlines important and repeated questions for the Programming for Problem Solving course (BSC-104-G) from 2021 to 2024, categorized by units covering C programming basics, control structures, arrays and functions, and structures, pointers, and file handling. Each unit includes questions of varying marks, detailing topics such as data types, control structures, arrays, and file handling functions, along with specific programming tasks. The document serves as a study guide for students preparing for exams in this subject.

Uploaded by

Gaming King
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

📘 Programming for Problem Solving (BSC-104-G) –

Repeated & Important Questions


(2021–2024)

📊 Marks Covered: 2.5 / 5 / 7 / 8 / 10 / 15 marks

📅 UNIT I – Basics of C Programming

• (15 marks) Explain the Data Types in C. Write a program that prints all data types.
Years: May 2024, May 2023, Dec 2024

• (8 marks) Define header files in C.


Years: May 2024, Dec 2024, Feb 2022

• (7 marks) What are storage classes in C? Explain.


Years: May 2024, Feb 2022

• (5 marks) Differentiate between Local and Global variables.


Years: Nov 2023, Dec 2024

• (10 marks) What are the types of operators used in C?


Years: Dec 2022, Feb 2022

• (5 marks) Explain constants and variables in C.


Years: Dec 2022

• (2.5 marks) What is a character set in C language?


Year: Dec 2024

• (10 marks) Write a flowchart and algorithm to find the largest of three numbers.
Years: Dec 2024, May 2023

• (5 marks) Write a pseudocode to check whether a number is even or odd.


Year: Nov 2023

• (15 marks) Explain the structure of a C program with an example.


Year: 2021

• (10 marks) Write an algorithm and flowchart to calculate the area of a rectangle.
Year: 2021

• (5 marks) Define variables and keywords with examples.


Year: 2021
📅 UNIT II – Control Structures and Functions

• (15 marks) Explain conditional branching in C. Write a program to find the greatest of four
numbers using if-else.
Years: May 2024, May 2023, Dec 2024

• (15 marks) What are iterations in C? Write a program for matrix multiplication.
Years: May 2024, Feb 2022, Nov 2023

• (15 marks) Switch case statement in C with suitable example.


Years: Dec 2024, May 2023

• (5 marks) Differentiate between while and do-while loops.


Year: Dec 2024

• (5 marks) What is the use of 'break' and 'continue' in loops?


Year: Feb 2022

• (15 marks) Explain various control structures used in C.


Year: 2021

• (10 marks) Write a program to print a multiplication table using for loop.
Year: 2021

• (5 marks) Differentiate between if-else and switch-case with example.


Year: 2021

📅 UNIT III – Arrays and Functions

• (15 marks) What are arrays? Write a program to multiply two matrices using arrays.
Years: May 2024, Dec 2022, May 2023

• (5 marks) Call by value vs Call by reference.


Years: May 2024, Feb 2022, Dec 2022

• (10 marks) Write a program to print Fibonacci series up to 10 numbers using recursion.
Years: May 2024, Dec 2022, Nov 2023

• (8 marks) What are different types of functions in C? Explain with example.


Years: Feb 2022, Dec 2022

• (10 marks) Write a program to find the factorial of a number using recursion.
Year: Nov 2023

• (15 marks) Explain the use of arrays in C with a program to find the sum of an array.
Year: 2021
• (10 marks) Write a program to generate the Fibonacci series using iteration.
Year: 2021

• (5 marks) Explain function prototype and its use in C.


Year: 2021

📅 UNIT IV – Structures, Pointers, and File Handling

• (15 marks) Describe array of structures with suitable example.


Years: May 2024, Dec 2024, Nov 2023

• (15 marks) What are pointers? How are they useful in DMA (Dynamic Memory Allocation)?
Years: May 2024, Nov 2023, May 2023

• (5 marks) Differentiate between structure and union.


Years: Nov 2023, Dec 2022

• (10 marks) What are file handling functions in C?


Years: Feb 2022, Dec 2024

• (10 marks) Write a program to read and write from a file in C.


Year: Dec 2024

• (2.5 marks) What is the use of 'sizeof' operator?


Year: Dec 2022

• (15 marks) What is a pointer? Explain pointer arithmetic with examples.


Year: 2021

• (10 marks) Write a program to store and display data using structures.
Year: 2021

• (5 marks) What is the difference between fscanf() and fgets()?


Year: 2021

Common questions

Powered by AI

The main difference between 'while' and 'do-while' loops in C is the order of execution of the loop body and the evaluation of the condition. A 'while' loop checks the condition before executing the loop body, leading to a situation where the loop body might not execute at all if the condition is false initially. Conversely, a 'do-while' loop executes the body once before evaluating the condition, ensuring that the loop body runs at least once. This difference affects scenarios where at least one iteration is required .

Using recursion to generate the Fibonacci series in C is elegant but can be inefficient due to repetitive calculations and increased function call overhead. Each call to calculate a Fibonacci term leads to two recursive calls, resulting in exponential time complexity and high stack usage, possibly causing stack overflow for large terms. Iterative approaches or memoization can significantly reduce computation time and resource utilization by eliminating redundant operations, demonstrating the trade-offs in recursive solutions .

'fscanf()' and 'fgets()' are both used for input in C but serve different purposes. 'fscanf()' reads formatted input from a file, using a format specifier to control data conversion, which is ideal for reading structured data like integers or floats. In contrast, 'fgets()' reads a full line or a defined number of characters until a newline is encountered, making it more suitable for text files requiring line-by-line processing. These differences guide their use based on the specific data handling requirements of a program .

Conditional branching structures in C, like 'if-else' statements, enable decision-making by evaluating conditions that determine which blocks of code should execute. These structures allow programmers to handle multiple conditions dynamically and adjust program behavior based on runtime scenarios. For example, to find the greatest of four numbers, the programmer can use nested 'if-else' statements to compare the four inputs and determine the largest number, enhancing flexibility and control .

Arrays and pointers form the backbone of effective data manipulation in C. Arrays facilitate sequential data storage with direct index-based access, essential for batch data operations like sorting and searching. Pointers add another layer of flexibility through direct memory address manipulation, enabling dynamic data structures like linked lists or trees. These features, combined, allow the efficient management of memory and complex data relations, pivotal in real-time or resource-constrained applications like embedded systems, highlighting the adaptability and power within C programming .

Pointers in C are variables that store memory addresses, allowing for efficient memory manipulation and dynamic allocation. They enable dynamic memory allocation (DMA) by using functions like malloc() and free(), facilitating the allocation or deallocation of memory during runtime, which is essential for efficient resource management in complex applications. However, incorrect use of pointers, such as dereferencing null or dangling pointers, can lead to undefined behavior, memory leaks, or segmentation faults, highlighting the complexity and risk associated with their use .

Function prototypes in C declare a function's interface before its actual implementation. They inform the compiler about the function return type, its name, and parameter types, enabling correct function usage verification during compilation. This avoids errors like incorrect argument types or return mismatch. For example, a prototype 'int sum(int, int);' ensures that subsequent function calls will provide two integers, otherwise a compile-time error occurs, thus aiding in code organization and error prevention .

Storage classes in C define the scope, visibility, and lifetime of variables or functions within a C program. The main storage classes are auto, register, static, and extern. 'Auto' is the default storage class for local variables, 'register' suggests storing the variable in a CPU register for quicker access, 'static' gives local variables a lifetime over the entire program, maintaining their value between function calls, and 'extern' extends the visibility of global variables to other files within a project. For instance, a static variable retains its value each time the function where it's defined is called, unlike a standard local variable which re-initializes .

Local variables in C are declared inside a function or block and are not accessible outside of that function, whereas global variables are declared outside of all functions and can be accessed by any part of the program. The scope of a local variable is limited to the block in which it is declared, and its lifetime ends when the block is exited. In contrast, a global variable's scope extends throughout the entire program and remains in existence for the program's duration. These differences affect how memory is allocated and can lead to more controlled data management in larger programs by limiting variable visibility .

Deciding between using a 'switch' statement and a series of 'if-else' statements involves considering readability, performance, and structure. 'Switch' is generally preferred for scenarios with numerous discrete values for a single variable due to its clarity and reduced complexity. However, 'if-else' provides more flexibility for complex conditions as it supports different conditional expressions. From a performance standpoint, 'switch' can be more efficient due to optimizations like jump tables, especially when evaluating constants .

You might also like