Programming For Problem Solving-Cse 1001-2024
Programming For Problem Solving-Cse 1001-2024
Group – A
1. Answer any twelve: 12 × 1 = 12
Choose the correct alternative for the following
(i) The address of the array element A[3][5] can also be represented as:
(a) *(A+3)+5 (b) &(A+3)+5
(c) *(*(A+3)+5) (d) *A[3]+5
(ii) Which is the correct way to declare a pointer to integer?
(a) int_ptr; (b) int *ptr; (c) *int ptr; (d) int ptr*;
(iii) What is the output of the following code snippet?
Group - B
2. (a) Perform the following base conversions:
(i) (6A7C.5D)16 = (?)10
(ii) (1472.65)8 = (?)2 [(CO1)(Remember/LOCQ)]
(b) Compute 5 – 18 using 2's complement method. Assume that each number is
stored using 1 byte. [(CO1)(Understand/LOCQ)]
(c) Draw a flowchart to accept a number from the user and determine whether it is
a palindrome number. [(CO3)(Apply/IOCQ)]
(2 + 2) + 3 + 5 = 12
3. (a) A float type variable X has the decimal value of –31.225. What is the
representation of X using the IEEE-754 single-precision 32-bit floating point
format? [(CO1,CO2)(Apply/IOCQ)]
(b) Calculate (10000100)2 – (1100110)2 using 2's complement binary arithmetic.
[(CO1,CO2)(Understand/LOCQ)]
(c) Find r such that (121)𝑟 =(144)8 , where r and 8 are the bases. [(CO1,CO2)(Apply/IOCQ)]
4 + 4 + 4 = 12
Group - C
4. (a) What will be the output of the following code snippet? Justify your answer.
[(CO5)(Analyse/HOCQ)]
(b) Explain explicit and implicit type casting with an example. [(CO4)(Remember/LOCQ)]
2
(c) Write a program to print the following pattern where the number of lines is
accepted from the user:
[(CO5)(Apply/IOCQ)]
3 + 3 + 6 = 12
5. (a) Write a C program that accepts two inputs, 'x' and 'n', and computes the value of
the series up to 'n' terms for a given 'x' without employing a distinct factorial
x2 x3 x4 x5
function: 𝑥 − + − + − ⋯ [(CO4,CO5)(Analyse/HOCQ)]
2! 3! 4! 5!
(b) Write a C program that takes a sentence or a line of text as input and displays
the frequency of each vowel, along with the total count of consonants.
[(CO4,CO5,CO6)(Remember/LOCQ)]
6 + 6 = 12
Group - D
6. (a) Determine the return value of the function call ‘fun(5)’ given the following
definition of the function 'fun'. Include the step-by-step working for clarity.
int fun (int n)
{
if ( n == 0)
return 1;
return 2 * fun ( n – 1 );
} [(CO5)(Analyse/IOCQ)]
(b) What is the purpose of the static keyword in C? Explain with an example. Can a
global variable be declared as static? Explain your answer. [(CO4)(Remember/LOCQ)]
(c) Write a code snippet to dynamically allocate a 2D integer array having 10 rows
and 15 columns. [(CO6)(Apply/IOCQ)]
(d) What is meant by the scope of a variable? [(CO4)(Remember/LOCQ)]
4 + (2 + 1) + 3 + 2 = 12
3
a++;
}
printf (“value of a is %d\n”, a);
a++;
}
printf (“value of a is %d\n”, a);
return 0;
} [(CO4)(Analyse/HOCQ)]
(b) What is a function? What are the advantages of using a function? Can a function
effectively utilize the 'return' keyword to send multiple values to the caller? If
so, what approach enables this? [(CO4,CO5)(Remember/LOCQ)]
5 + (1 + 2 + 4) = 12
Group - E
8. (a) How can you check whether a file exists by using the fopen( ) function?
[(CO5,CO6)(Apply/LOCQ)]
(b) State the uses of fseek( ), ftell( ) and rewind( ) functions. [(CO6)(Remember/LOCQ)]
(c) Develop a C program that compares two dates provided by the user. Define a
structure called 'Date' to hold the day, month, and year components of the dates.
If the dates are identical, output 'Dates are equal'; otherwise, display 'Dates are
not equal'. [(CO5,CO6)(Apply/IOCQ)]
3 + 3 + 6 = 12
9. (a) Create a structure student with the fields name, roll_no, gender and section.
Dynamically create an array of n students and store their information by
accepting data from the user. Then display the names and roll numbers of all
male students of section B. [(CO6)(Analyse/IOCQ)]
(b) Write a C program which accepts the name of a file as a command line argument
and searches for that file in the current working directory. If the file is found, the
program computes the size of the file. Recall that each character contributes one
byte to the overall size. [(CO6)(Remember/IOCQ)]
6 + 6 = 12
*LOCQ: Lower Order Cognitive Question; IOCQ: Intermediate Order Cognitive Question; HOCQ: Higher Order Cognitive Question.