0 ratings0% found this document useful (0 votes) 554 views10 pagesPPS Pyqs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Bihar Engineering University, Patna
B.Tech. 2" Semester Special Examination, 2024
Course: B.Tech. Time: 03 Hours
Code: 100204 ‘Subject: Programming for Problem Solving Full Marks: 70
Instructions:- : - =
(i) The marks are indicated in the right-hand margin.
(ii) There are NINE questions in this paper.
(iii) Attempt FIVE questions in al
(iv) Question No. 1 is compulsory.
Q.1 Choose the correct option /answer of the following (Any seven question only): [2x7=14]
(2) What is the return type of the fopen() function in C?
(i) A void pointer (ii) A character pointer
) Pointer to file object Av) An integer pointer
(b) What isthe output of the following C code.
Hinclude
int main)
{
int d, a=1,b=2;
d= ath + Hb;
printf"%d %d Yd, d, a,b);
}
@ 324 (i) 423 Giiy3.44 (i433
(©) What is void pointer.
(€) Write the names of entry controlled and then exit controlled loops in C.
(©) (G75)a = (Dro, Whabis the value of y?
(8) Whats the output ofthe following C code
include
void main) -2
double k=0;
for(k“0.0; k<3.0; K+)
printi%6E",k);
}
(@ 2.000000 i) 3.000000 ity 4.000000 (iv) None of these
(g) How is the 3" element in an array a is accessed based on pointer notation?
(ta43 (iy "(a+3) Gil) *(¢a +3) (iv) &(a+3)
(h) Which one of the following is NOT @ Bitwise operator?
o= Gl (ii) && iw<<
(i) Language C uses
(i) call by value (ji)call by address (ili) eallby name _(iv) Only () and (i)
@ A function may contain
(i) one return statement
(ii) more than two retum statements (iv) none ofthese
(Gi) bwo return statements
Page 1 of 2Q2
03
4
Os
06
Q7
as
@
()
©
(@)
(b)
Oy
(@
(b)
@
(b)
@
(b)
@
()
Write @ comparative study between for, while and do-while loop.
Write a program in C to find all the prime numbers in the range {0 to 100.
Explain with suitable example, the difference between structure and union,
Write a C program to read m unsorted integers to an array of size n and pass the
array to @ function to sort the integers into ascending order using bubble sort
technique,
‘What are the different storage classes in C, Explain each of them in detail
List all the shapes used in the flowchart, Draw the flowchart to illustrate the,
concept of break and continue statements taking suitable examples. >
What do you mean by tail recursion. Explain with an example
Define a structure Student that consist ofthe following members: Reg’No, Name,
DoB and marks of three subjects. Use nested structure for DeB. Write a C
program to input details for 10 students. Also, it should calculate age and average
marks obtained by these students as output
Write a C program to generate Fibonacei series till-n"™ term without using
recursion.
Write a C program that implements string copy’ funtion SerCpy(Sert, Str2). This
function copies the string Seri to another String Ser2' without using. library
functions.
Write a program to read a file and display its contents along with line number
before each line
Write a program in C which prints all the digits of a positive integer number
entered by user into words. Eg. If 732 is entered through the keyboard, the
program should output “seven three two”,
How do you access a structure variable through a structure pointer? Explain with
‘example program.
Write a € program to print the following pattern (tll rows, where m is taken as
input)
aaa
Write a complete C program to find out the Trace of a square matrix [Trace means
the sum of Principal Diagonal Elements)
Write short notes on any two of the following:
(@
(b)
©
@
Pointer Arithmetic
Dynamic Memory Allocation
Amy of Pointers
Bitwise Shift Operator
Page 2 of 2
51
{4
5]
i
tt
18]
16
191
151
"71
vm
18]
[61
Is)
16
[nx2-14]Bihar Engineering University, Patna
B.Tech. 1 Semester Examination, 2023
Course: B.Tech. Time: 03 Hours
Code: 100104 Subject: Programming for Problem Solving Full Marks: 70
Tnsructons:
0) The marks are indicated inthe righ-hand margin.
(i) There are NINE questions in this paper,
(ii) Attempt FIVE questions inal.
(09) Question No. 1s compulsory.
Q.1 Choose the correct answer of the following (Any seven question only): [2x7= 14
(a) What is the output ofthe following code?
int x= 10;
printi"96d", x);
(Error (ii) 10 Gyn (
(©) Which function is used to dynamically allocate memory in C?
(malloc) —_—_tipealloc) (ii) realoc) (Gv) all of the above
(©) What is the output ofthe following code?
#inelude
int main() {
char *p
pete
print”
return 0;}
(H tewill prine'a’ iy twill print ii) Compile time error (iv) Runtime error
(@) What are the elements present in the array of the following C code?
int aray[6] = (5):
@5.5,5.5.5.5 (ii) 5,0,0,0,0,0
Gi) 6, 6, 6,6.6,6 (iv) (garbage). (garbage). (garbage), (garbage), (garbage). 5
(©) What will be the output ofthe following C code?
void main(){
int i=0:
while ('< 10)¢
printf(“hiin")
while ((<8){
printf("hello\n")3}})
(j) his printed 8 times, helo 7 times and then hi 2 times
(ii) hi is printed once, hello 7 times
{Gii) hi is printed once, hello 7 times and then hi 2 times
(iv) None of the above.
(©) What does the following declaration mean?
int (*ptr) {10};
(O ptris array of pointers to 10 integers. (ii) ptr isa pointer to an array of 10 integers.
=P):
(iii) ptr is an array of 10 integers. (iv) ptr isa pointer to array of 10 characters.
(@) Cis type of programming language?
(® Object Oriented (Gi) Procedural
(iii) Bit level language (iv) Functional
(h) Choose the right C statement.
(@ int my_age = 10: Gi) int my.age = 10;
(ity my age = 10; (iv) Allare correct
Page 1 of 2o2
03
4
as
26
a7
8
oo
a
oO
@
b)
@
(b)
@
o
@
@)
(@)
e)
(@)
(b)
(a)
(b)
(a)
(b)
Consider the following integer 2D array, which is stored in memory with the base
address 1400. What would be the address of the element 14? [Assume that an integer
value takes 4 bytes of memory space.]
in afS]05I= (1 5}. (6.7.8,9,10}.(11,12,13,14,15}}:
( 1440 Gi 1444 Gi 1448 iv) 1452
Consider the following declaration of the variables:
int x. ALSI6]. *P=SA(0][0]:
Which of the following is/are the correct expression(s) to access A(3]{S] and assign it to
x27; Cid)
1(A43)45);
(p+28); Gi) x=(1(A45)43), Civ)
Explain the difference between auto and static type storage variables with suitable
example codes.
Differentiate between structures and unions in C, Write a C program to detect
‘whether the computer is little endian or big endian using unions.
Write an efficient C program to search if the integer 24 is present in the given
sorted array or not. I it is present, print the index where itis found.
Explain the insertion sort algorithm and its steps using an example. Consider the
array: (5, 2.4, 6.1.3].
Describe the concept of pointers in C programming language. Explain how
Pointers work and discuss their importance in programming, particularly in
‘memory management and efficient data manipulation,
Write a C program to copy contents of one file to another. While doing so replace
all lowercase characters to their equivalent uppercase characters.
Write a C Program to find the Euclidian distance between two points P(x, y) and
Q(e,b) using structure representation of points P and
Differentiate berween call-by-value and call-by-reference with suitable examples.
Define arays in C and explain their declaration and usage. Write a C program to
reverse the content of an integer array without using auxiliary array.
Define implicit and explicit type casting in C. Provide code examples illustrating,
when each type of casting occurs and their potential side effects.
Explain the concept of nested loops. Describe how the break and continue
statements alter the flow of control within C loops.
Explain the concept of algorithmic complexity and its significance in computer
science. Using examples, illustrate how different algorithms exhibit various orders
of complexity. such as constant time (O(1)), linear time (O(n), logarithmic time
(O(log n). quadratic time (O(n). and exponential time (O@").
‘The first 6 numbers of the Fibonacci series are: 0 1123.5. Write a C program
using recursion to find and prin the Fibonacci series for frst n terms.
Weite a C program using recursion to find factorial of a given number
Write aC program for the following:
(i) Reverse a string without using strrev().
i). Concatenate two strings without using streat().
Write a C program to find result matrix after multiplying two given matrices using
2-D arrays. Check the multiplication criteria also while deriving the logic.
Page 2 of 2
vm
71
71
ul
v7
(71
71
71
U7
7
71
71
(71
71
7
miBihar Engineering University, Patna
End Semester Examination - 2023
Course: B.Tech. Semester- 11 Time: 03 Hours
Code: 100204 Subject: Programming for Problem Solving Full Marks: 70
Instructions:~
(The marks are indicated in the right-hand margin.
(ij) There are NINE questions in this paper.
(iii) Attempt FIVE questions in all.
(iy) Question No, 11s compulsory.
Q.1 Answer any seven question of the following: 2x7=14)
(a) Which of the following is a keyword used for a storage class?
(o Printt (ii) extemal Gi) auto (iv) seanf
(b) Pointers are of
(i) integer data type (ii) character data type
ii) unsigned integer data types Aiv) none of these
(©) What is the output of betow program?
Void main (){
Chair *p= “Hello wor
Int*q;
ee
a= (int *)p3
q
printf( “/n %s\n%s", p.q)s}
ello world Gi) Compiler error
Ello world
Gil) lo world {iv) eto world
lo world world
(4) The minimum number of comparisons required to find the minimum and the maximum
of 100 numbers is
(i 100 Gi 200 Gi) 150 Gv) 148
(©) Which of the following is a correct format for declaration of function?
(i) returt-type function-name (argument type);
(ii) retir-type function-name (argument type) {}
(iii) return-type (argument type) function name;
{iv),All of the above
() What is the output of this C code?
Hinclude
Void main ()
{
intb=6;
inte=7;
inta=++b+c--;
+
(@ Runtime error Gis (
i) 13, (i 4
(g) Identify the correct sequence of steps to run a program.
Link, load, code, compile and execute (ii) Code, compile, link, execute and load
Page 1 of 3Q2
o4
Qs
Q6
(iii) Code, compile, link, load and execute (iv) Compile, code, link, load and execute
(bh) Why do we write (int*)before malloc?
Int*ip=(int* )malloc(sizeoftint));
(i) It is for the syntax correctness (Gi) It is for the type casting
(iii) Its to inform malloc( ) function about data-type expected
(iv) None of the above
(What is the disadvantage of arrays in C2
( The amount of memory to be allocated should be known beforehand.
(ii) Elements of an array can be accessed in constant time.
(iii) Elements are stored in contiguous memory blocks.
(iv) Multiple other data structures can be implemented using arrays.
(What wil be the output of the following code snippet?
Hinclude
void Solve (){
printf ("hd ”, 9/2);
printf "%6E" , 9.0/2);
}
int main () {
solvet )5
return 0;
}
(44.5000 (i 44.000 (iii) 4.5000 4.5000 (ivyas
(@) Discuss different looping constructs available in C. oy
(b) Which of these constructs are exit controlled? Explain with example flowchart. BI
(©) Elaborate the role of break and continue statements in loops. im
Write a C program for any two of the following: [7x2=14]
(@) Reverse a string without using sirrev( )
(b) GCD of two numbers
(©) Solution for Tower of Henoi problem.
(@) Multiplication of wo matrices
(2) How can an array of numbers be passed to function as parameter? Write an example [6]
Of C program in support.
(b). What do you understand by operator precedence? Explain. 4
(©) What are the libraries? How are they different from header files? 4
(a) Write a program in C to find out the greatest number out of three numbers using "1
conditional operator
(b) Explain different file opening modes. Write a program to read the content ofa given [7]
file and display the number of lines and words in that file.
(@) Write a program in C to enter the records of 100 employees and display the names [8]
of those who eam more than Rs. 20,000. Create a suitable structure to keep
employee records about their code, name, designation and salary.
Page 2 of 37
os
29
(6) Write a program in C to print the following pattern: 14
1
23
456
78910
T1213 14 seu
(a) Whats dynamic memory allocation. Explain calloc( ), malloc ), realloc( ) and 161
free() functions with suitable examples.
(b) Write a program in C using functions to swap two numbers using concept of global > (8}
variables and call-by-reference concept. ee
(a) _ Explain command line arguments in C with the help of an example. ‘ 61
(b) Write a function in C to implement selection sort technique. ae 6)
(©) Which of the sorting algorithm is better than other. Explain. BI
Write short notes on any two of the following: [7x2=14]
(a) Enumerated data types
(b) Storage classes in C
(c) Nested if-else Vs Switch
(a) Recursion : a?
Page 3 of 3Bihar Engineering University, Patna
B.Tech. 1" Semester Special Examination, 2024
Course: B.Tech.
Code: 100104 Subject: Programming for Problem Solving
Instructions:-
(The marks are indicated in the right-hand margin.
(Gi). There are NINE questions in this paper.
(Gil) Attempt FIVE questions inal
(iv) Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (Any seven question only):
(a) What would be the output ofthe following program?
int main()
float a=3.15529;
print(n¥66.2¢"
1
3.16 (i313 (iii) Compilation error
(b) Which of the following is true about argv?
(i) It is an array of character pointers
(i) It is a pointer to an array of character pointers.
(ii) It is an array of strings .
(iv) None of the above
(©) What would be the output of the following program?
int main
printf("%s", p);
4
(i) abnjayC-Test (ii) Sanjay C-Test
(iii) Compile (jy) Runctime error
(@) Determine the output for the given program:
Finclude
fdefine mulls) x*8
int main()
int ymnul( 10/3);
printt(“%d", y);
)
@o (i 24 dil) 24.33
Time: 03 Hours
Full Marks: 70
[2x7=14)
(iy 3.15529,
(iv) 26.64
(e) What would happen if you assign a value to an element of an array whose subscript exceeds
the size ofthe array?
(@ the element will be set to 0 Gi nothing, it's done all the time
(Gli) other data may be overwritten (iv) error message from the compiler
Page 1 of 32
0.3
4
os
26
wo
(s)
@)
@
oO
(a)
()
@
(b)
@
(by
@)
)
@
)
‘What will be the output ofthe following C code?
int main()
(
signed char ch;
chr = 128;
printf("%d\n", ch);
return 0;
}
ors (i)-128 (ii) depends on the compiler (iv) none of the above
‘The hexadecimal equivalent tothe number (101101010010) is:
ass (vas Gil) BS2 (iv) C62
‘The correct syntax to send an array ‘arr as.a parameter toa function ‘func’ is
() func(arry: (i) Fune(&are), (ii) Fune(tarr; Gv) Mane(artsize):
Arheader file is:
(A file that contains standard library functions
) A file that contains definitions and macros
(ii) A file that contains user-defined functions
(iv) A file that is present in current working directory
‘The expression, = 7/22 * (3.14 + 2) + 3/5 vevildates to:
(s2s Gin 628 Gi 3.14 ao
A S-digit positive integer is entered thyough the keyboard, write a recursive
function to calculate sum of digits of the’ given number.
Explain compile-time and run-time initialization of array with suitable examples.
Differentiate between entry, and exit controlled loops with suitable examples
(flowcharts)
Write a program in C to print the following pattern:
436
78910..
‘Sort the following numbers in ascending order: 12,6,17,4,2,9, 5 using insertion
Sort technique. Give clear explanation for every pass.
Write your own version of string manipulation functions xstrlen() and xstrepy() to
‘mimnic standard library functions strlen() and strepy(.
Write a program in C that converts a string like "124" to an integer 124.
Differentiate between structure and union. Write an example situation where
tunion is more suitable than structure,
Write a program in C to copy one file to another. While doing so replace all
lowercase characters to their equivalent uppercase characters,
What isthe relation between array and pointer? What is array of pointers? Explain
with examples.
Page 2 of 3
7
m1
71
m
(7
(71
m
im
(71
(71Q7
os
@
(b)
(a)
()
‘Multiple return statements are allowed within a function but a function cannot
return more than one value. Explain with example.
Differentiate between break and continue statements with examples. How does
break differ from exit() ?
Explain cal-by-value and call-by-reference with examples. Differentiate between
ruil and void pointer.
Write a program to find the greatest of the three numbers entered through the
Keyboard, first using nested if-else construct, and then using conditional operators.
Write short notes on any two of the following:
(a). Pointer to an array
(b)_Bitwise shift operators
(©) Linked list
(@)_ Dynamic allocation of memory
Page 3 of 3
71
71
1
7
[n2=14]