You are on page 1of 4

A000213(022)

B. Tech. 2nd Semester Class Test – II -2020


Subject Name : Programming for Problem Solving
Time: 3 Hrs. Maximum Marks: 100

Note: Attempt all five questions as per given internal choice. Each question carries 20 marks.

C113.1 Formulate Algorithms for solving logical and numerical problems.


C113.2 Apply appropriate control constructs for logical and arithmetic problem solving.
C113.3 Identify and use arrays and strings as data structures for data searching and sorting tasks.
C113.4 Build logic for performing modular programming.
C113.5 Identify suitable data storage types and structures to perform various data processing tasks.

Q. No. Questions Marks CO BL PI


1 a) i. Who developed C Programming Language? (4) C113.1 L2 1.4.1

ii. The word ____________comes from the name of a Persian C113.1 L2 1.4.1
mathematician Abu Jafar Mohammed ibn-i Musa al Khwarizmi.

iii. To repeat a task number of times we use _______________statement. C113.1 L2 1.4.1

iv. The below symbol is used for__________________________________ C113.1 L2 1.4.1

b) i. What are the qualities of a good algorithm? (6) C113.1 L2 1.4.1

OR

i. Write down the advantages of flowchart. C113.1 L2 1.4.1

ii. Draw a flow chart to add two numbers entered by an user. C113.1 L2 1.4.1

OR

ii.Write the basic components of a computer. C113.1 L2 1.4.1

c) i. Write an algorithm to find all the roots of a quadratic equation (10) C113.1 L3 1.4.1
ax 2 + bx + c = 0
OR

i. Differentiate between primary memory and secondary memory. C113.1 L2 1.4.1

OR

i. Draw a flow to find the largest among three different numbers C113.1 L2 1.4.1
entered by user.

2 a) i. What will be the output of the C code: (4) C113.2 L3 1.4.1


#include <stdio.h>
int main()
{
int i=0;
switch(i)
{
case '0' : printf("BIT");
break;
case '1' : printf("Durg");
break;
default : printf("BIT Durg");
}
return 0;
}
ii. How many times will "BIT" print? C113.2 L3 1.4.1
#include <stdio.h>
int main()
{
int a=5;
while (a>=3)
{
printf("BIT\n");
a--;
}
printf("Clean Campus");
return 0;
}
iii. What will be the output of the C code: C113.2 L3 1.4.1
#include <stdio.h>
int main()
{
int i=0;
for(printf("1");i < printf("0");i++)
printf("1");
return 0;
}
iv. What will be the output of the C code: C113.2 L3 1.4.1
#include <stdio.h>
int main()
{
int i;
for(i=7;i!=0;i--)
printf("%d",i--);
return 0;
}
b) i. What do you mean by data types? Explain basic data types used in ‘C’ (6) C113.2 L2 1.4.1

OR

i. What is ternary operator? C113.2 L2 1.4.1

ii. Differentiate between while loop and do while loop. C113.2 L2 1.4.1

OR
ii. Differentiate between break and continue. C113.2 L2 1.4.1

c) i. Write a C program to input electricity unit charges and calculate total (10) C113.2 L3 1.4.1
electricity bill according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill.
OR

i. Write a C program to enter any number and print its reverse. C113.2 L3 1.4.1

OR
i. Write a C program to display the pyramid pattern. C113.2 L3 1.4.1
*
***
*****
*******
*********
3 a) i. What will happen if in a C program you assign a value to an array (4) C113.3 L2 1.4.1
element whose subscript exceeds the size of an array?

ii. An array Index starts with.? C113.3 L2 1.4.1

iii. How to declare an 1D array of integer type? C113.3 L2 1.4.1


iv. int aaray2d[][4]={1,2,3,4,5,6,7,8}; C113.3 L2 1.4.1
is it valid declaration?(Yes/No)
b) i. What is the use of %s format specifier? Explain with Example. (6) C113.3 L2 1.4.1

OR

i. What is the importance of null character in strings? Explain with C113.3 L2 1.4.1
Example.

ii. Write a C statement to declare and initialize a matrix of 2 rows and 4 C113.3 L3 1.4.1
columns and display the value of 2nd row 3rd column.

OR

ii. Write a C statement to declare and initialize a matrix of 4 rows and 2 C113.3 L3 1.4.1
columns and display the value of 3rd row 2nd column.

c) i. Write a C code to Sort the elements of an integer using Selection Sort. (10) C113.3 L3 1.4.1
Demonstrate the working of Selection Sort technique.

OR

i.Write a C program to display the diagonal elements of a square matrix. C113.3 L3 1.4.1

OR

i.List and explain any 5 library functions on strings. C113.3 L2 1.4.1

4 a) i. A function is used to________. (4) C113.4 L2 1.4.1

ii. The keyword used to transfer control from a function back to the C113.4 L2 1.4.1
calling function is_____________.

iii. A function that calls itself is called a ___ function. C113.4 L2 1.4.1

iv. A function prototype is used for______________. C113.4 L2 1.4.1

b) i. Explain function prototyping. (6) C113.4 L2 1.4.1

OR

i. What is the role of return statement in a user-defined function? C113.4 L2 1.4.1

ii. What is actual and formal arguments. C113.4 L2 1.4.1

OR

ii. Why we are using recursion ? C113.4 L2 1.4.1

c) i. Write a program using function to calculate the factorial value of any (10) C113.4 L3 1.4.1
integer entered through the keyboard.

OR

i. Write a c program to swap two integers using call by value and call by C113.4 L3 1.4.1
reference.

OR

i. Write a program to generate Fibonacci series using recursion. C113.4 L3 1.4.1

5 a) i. What will be the output of the C code: (4) C113.5 L3 1.4.1


#include <stdio.h>

int main()
{
char *ptr="*&*&*(ptr+1)";
printf("%c",*&*&*(ptr+1));
return 0;
}
ii. What will be the final value of 'a'? C113.5 L3 1.4.1
#include <stdio.h>
void fun(int*);
int main()
{
int *ptr, a=5;
ptr= &a;
fun(ptr);
return 0;
}
void fun(int *p)
{
printf("%d",(*p)++);
}
iii. What will be the output of the C code: C113.5 L3 1.4.1
#include <stdio.h>
int main()
{
struct stud
{
int roll;
char name[30];
}s;
strcpy(s.name,"CoronaVirus");
printf("Stay safe from %s",s.name);
return 0;
}
iv. The__________ function is used to read a single character from a file C113.5 L2 1.4.1
at a time.

b) i. What is Pointer in C programming ? How it is Declared? (6) C113.5 L2 1.4.1

OR

i. How many types of pointers are there in C Programming. C113.5 L2 1.4.1

ii. How structures are used in a C program? C113.5 L2 1.4.1

OR

ii. What does the characters "r" and "w" mean when writing programs C113.5 L2 1.4.1
that will make use of files?

c) i. Explain various file opening modes in C. (10) C113.5 L2 1.4.1

OR

i. Create a structure student to store the name, roll no and percentage of C113.5 L3 1.4.1
the student. Enter some values within the structure and print the details
of the student with maximum percentage.

OR

i. Explain the following file functions with example : C113.5 L2 1.4.1


1.fopen() 2. fgets() 3. fputs()
4.feof() 5. fseek() 6. ferror()

You might also like