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

C Programming Exam Questions Guide

1. The document contains 10 questions divided across 5 modules on the topic of C programming for problem solving. It provides instructions to answer any 5 full questions, choosing 1 from each module. 2. The questions assess a variety of C programming concepts like basic program structure, operators, input/output, decision making statements, arrays, functions, pointers, structures and preprocessor directives. 3. Students are required to write code snippets or full programs to demonstrate their understanding of the concepts. They must also explain concepts, provide examples and derive mathematical expressions in C code.

Uploaded by

iqrafarheen675
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 views2 pages

C Programming Exam Questions Guide

1. The document contains 10 questions divided across 5 modules on the topic of C programming for problem solving. It provides instructions to answer any 5 full questions, choosing 1 from each module. 2. The questions assess a variety of C programming concepts like basic program structure, operators, input/output, decision making statements, arrays, functions, pointers, structures and preprocessor directives. 3. Students are required to write code snippets or full programs to demonstrate their understanding of the concepts. They must also explain concepts, provide examples and derive mathematical expressions in C code.

Uploaded by

iqrafarheen675
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

[Link] [Link].

com
,.../

USN 18CPS13/23
11
First/Second Se B.E. egree Examination, Dec.2019/Jan.2020
C Programming for Problem Solving
Time: 3 hrs. Max. Marks: 100
Note: Answer any FIVE full questions, choosing ONE full question front each module.

Module-1
How would you explain the components of a computer with the block diagram? (08 Marks)
Describe the types of computers. (06 Marks)
Convert the following mathematical expression into C equivalent statements.
4
Y
i) m = x + X + — — 4x +6
k
— b + \r/ b 2 —4ac
ii) x=
2a
2
iii) Area = irr + 27trh (06 Marks)

OR
2 a. How can you write the basic structure of a C program? Explain with examples. (08 Marks)
b. Define a token. Explain the different tokens available in C language. (08 Marks)
om

c. How would you explain logical operator in a C language. (04 Marks)


r.c

Module-2
ke

3 a. With examples how would describe the formatted input and thrmatted output statements in
C language. (08 Marks)
an

b. How would you explain if— else statement in C language? Give the relevant ex ample.
tR

(06 Marks)
irs

c. Write a program in C to display the grade based on the marks as follows :


Marks Grades
.F

0 to 39 F
w

40 to 49 E
w

D
w

50 to 59
60 to 69 C
70 to 79 B
80 to 89 A
90 to 100
(06 Marks)

OR
4 a. How would you explain switch statement with an example? (08 Marks)
b. How the while loop differs from do-while loop? (06 Marks)
c. Write a program to check whether a given integer is palindrome or not? (06 Marks)

CC Module-3
0
5 a. Define an array. How would you explain declaration and. initialization of one dimensional
C array? (06 Marks)
b. Write a program in C to implement binary searching technique. (06 Marks)
c. How would you explain with examples, the string manipulation functions? (08 Marks)
[Link]
[Link] [Link]

1 8CPS13/2.3

OR
6 a. Write a program to read N integers and to arrange them in ascending order using bubble sort
technique. (06 Marks)
b. How would you explain the declaration and initialization of string variables? (06 Marks)
c. Write a program to multiply 2 matrices, by ensuring their multiplication compatit )ility.
(08 Marks)

Module-4
7 a. How would you illustrate the elements of user defined functiOns with examples? (10 Marks)
b. Write a program in C to find the factorial of a given integer using functions. (05 Marks)
c. Explain how call by value differs from call by reference while invoking a functio n.
(05 Marks)

OR
8 a. How would you explain the categories of user defined functions? (10 Marks)
b. Write a program in C to compute the Fibonacci series up to n terms using recursi on.
(06 Marks)
c. List the storage class specifiers. Explain any one of them. (04 Marks)
om

Module-5
9 a. Define a structure. How would you declare and initialize structure variables? Give examples.
r.c

(07 Marks)
b. Define a Pointer. How the pointers are declared and initialized?
ke

(06 Marks)
c. Write a C program to read details of 10 students and to print the marks of the student if his
an

name is given as input. (07 Marks)


tR
irs

OR
10 a. Write a program in C to add two numbers using pointers. (05 Marks)
.F

b. How would you explain the categories of preprocessor directives in C? (10 Marks)
w

C. How would you explain nested structures? (05 Marks)


w
w

[Link]

Common questions

Powered by AI

Arrays facilitate data organization and manipulation by allowing the storage of multiple elements of the same data type in contiguous memory locations, enabling indexed data access and manipulation. A one-dimensional array can be declared using the syntax: data_type array_name[array_size], where data_type is the type of elements the array will hold. An example of initialization is: int numbers[5] = {1, 2, 3, 4, 5}; which declares an integer array named numbers with five elements initialized to specified values .

Nested structures in C programming allow the inclusion of structures within structures, facilitating complex data organization and modeling hierarchical relationships. This approach is beneficial for applications like database systems where multi-faceted data entities must be represented. For example, struct Address { char street[50]; int zip; }; struct Employee { char name[50]; struct Address addr; }; allows encapsulation of related attributes, improving data handling, structuring, and code clarity .

Call by value sends the actual value of a variable as parameter to a function, meaning changes made to the parameter within the function do not affect the original variable. In contrast, call by reference sends the address of the variable, allowing the function to modify the original variable's value. This impacts program behavior significantly as call by value ensures data safety and integrity while call by reference is more efficient for handling large data structures or when modifications are needed .

The if-else statement in C language enhances decision-making by allowing the program to choose between two alternatives based on a condition evaluated at runtime. If the condition is true, the first block of code is executed; otherwise, the block following the else clause is executed. For example, consider a program that checks if a number is even or odd: if (number % 2 == 0) { printf('Even'); } else { printf('Odd'); } .

Storage class specifiers in C determine the scope, lifetime, and visibility of variables which affect how they are accessed and retained throughout the program execution. The 'static' specifier, for example, restricts variable visibility to the function or file in which it was declared but extends its lifetime to the entire program duration. Thus, a static variable retains its value between function calls, unlike a normal local variable that resets each time. For instance: static int count = 0; ensures count retains its incremented state across invocations .

User-defined functions in C programming allow developers to create custom operations tailored to specific needs, promoting code reusability and modular design. They differ from library functions, which are predefined in libraries and perform generic tasks. A user-defined function example is a factorial calculator: int factorial(int n) { if(n <= 1) return 1; else return n * factorial(n - 1); }, which enables recursion to calculate factorial values .

String manipulation in C requires specialized functions because strings are treated as arrays of characters terminated by a null character '\0'. Unlike numeric data types, strings require functions like strcpy(), strcat(), and strlen() for copying, concatenation, and length determination, respectively. These functions handle character-specific operations essential for manipulating sequences efficiently and safely, unlike simple arithmetic applicable directly to numeric arrays .

Pointers in C offer significant advantages, particularly with dynamic memory allocation and data manipulation. They allow programs to allocate memory at runtime, optimizing memory usage and enabling efficient management of large data structures. Pointers provide direct access to memory locations, facilitating advanced data manipulation techniques such as sorting or linked list operations. This capability enhances performance and flexibility in complex programs, effectively managing resources and expanding functionality .

Loop structures in C programming enable repetitive execution of code blocks. The key difference between 'while' and 'do-while' loops is in execution condition. A 'while' loop checks the condition before entry, potentially not executing the block if the condition is false initially. Conversely, a 'do-while' loop checks the condition after executing the block, ensuring at least one execution regardless of condition outcome. These structures facilitate efficient iterative operations necessary for tasks such as traversals in data processing .

Preprocessor directives in C, such as #define, #include, and #ifdef, significantly impact program efficiency and compilation by pre-processing code before compilation. They allow macro definitions, conditional compilation, and library inclusions, optimizing code for performance and adaptability. Their use can simplify and streamline the code, reduce repetition, and control compilation logic, thus influencing efficiency by excluding unnecessary code segments and managing resources effectively .

You might also like