Cse Programming For Problem Solving Tutorial Question Bank
Cse Programming For Problem Solving Tutorial Question Bank
(Autonomous)
Dundigal, Hyderabad - 500 043
COURSE OBJECTIVES:
The course should enable the students to:
I. Learn adequate knowledge by problem solving techniques.
II. Understand programming skills using the fundamentals and basics of C Language.
III. Improve problem solving skills using arrays, strings, and functions.
IV. Understand the dynamics of memory by pointers.
V. Study files creation process with access permissions.
ACSB01.01 Identify and understand the working of key components of a computer system.
ACSB01.02 Analyze a given problem and develop an algorithm to solve the problem.
ACSB01.03 Describe the fundamental programming constructs and articulate how they are used to develop a
program with a desired runtime execution flow.
ACSB01.04 Gain knowledge to identify appropriate C language constructs to write basic programs.
ACSB01.05 Identify the right data representation formats based on the requirements of the problem.
ACSB01.06 Describe the operators, their precedence and associativity while evaluating expressions in program
statements.
ACSB01.07 Understand branching statements, loop statements and use them in problem solving.
ACSB01.08 Learn homogenous derived data types and use them to solve statistical problems.
ACSB01.09 Identify the right string function to write string programs.
ACSB01.10 Understand procedural oriented programming using functions.
ACSB01.11 Understand how recursion works and write programs using recursion to solve problems.
ACSB01.12 Differentiate call by value and call by reference parameter passing mechanisms.
ACSB01.13 Understand storage classes and preprocessor directives for programming
ACSB01.14 Understand pointers conceptually and apply them in C programs.
ACSB01.15 Distinguish homogenous and heterogeneous data types and apply them in solving data processing
applications.
ACSB01.16 Explain the concept of file system for handling data storage and apply it for solving problems
ACSB01.17 Differentiate text files and binary files and write the simple C programs using file handling
functions.
ACSB01.18 Identify the right string function to write string programs.
ACSB01.19 Understand procedural oriented programming using functions.
ACSB01.20 Understand how recursion works and write programs using recursion to solve problems.
TUTORIAL QUESTION BANK
MODULE - I
INTRODUCTION
Part - A (Short Answer Questions)
S No Questions Blooms Course Course
Taxonomy Outcomes Learning
Level Outcomes
(CLOs)
1 List the two major components of a computer system? Remember CO 1 ACSB01.01
2 Identify the steps in creating and running a C program? Remember CO 1 ACSB01.03
3 What are the different types of computing environments? Remember CO 1 ACSB01.02
4 Define a flowchart and the symbols used in it? Understand CO 1 ACSB01.03
5 State the properties of an algorithm? Remember CO 1 ACSB01.02
6 List out the generations of computers? Understand CO 1 ACSB01.02
7 What are the different types of computer programming languages? Understand CO 1 ACSB01.02
8 Write the various classes of data types ANSI C supports? Remember CO 1 ACSB01.05
9 State which of the following are valid identifiers. If invalid, state the Understand CO 1 ACSB01.05
reason.
1. sample1
2. data_7 return
3. #fine 91-080-100
4. name &age
5. _val
10 What are the C tokens? Remember CO 1 ACSB01.05
11 List out the rules for identifiers? Remember CO 1 ACSB01.05
12 What is type casting and list its types? Understand CO 1 ACSB01.05
13 Write the basic structure of a C program? Understand CO 1 ACSB01.05
14 Define ternary or conditional operator with an example? Understand CO 1 ACSB01.06
15 Find the value of x in the following expression? x = 3 / 2 % 6 – 3 / 9; Understand CO 1 ACSB01.06
16 List out the bit-wise operators in C? Understand CO 1 ACSB01.05
17 Write the size and range of the fundamental data types? Remember CO 1 ACSB01.05
18 Explain the various key words related to data types and loops? Remember CO 1 ACSB01.04
19 List out logical operators used in C language? Understand CO 1 ACSB01.06
20 Write the basic escape sequence characters and its meaning with Remember CO 1 ACSB01.06
example?
Part - B (Long Answer Questions)
1 Explain the fundamental data types along with its size and range? Understand CO 1 ACSB01.03
2 Explain bit-wise operators with example? Understand CO 1 ACSB01.05
3 Explain the following functions with example? Understand CO 1 ACSB01.06
i. getc()
ii. putc()
iii. gets()
iv. puts()
4 Explain the salient features and applications of C language? Understand CO 1 ACSB01.05
5 Explain the modifiers used for data types in C language? Understand CO 1 ACSB01.06
6 Explain type conversions in C with example? Understand CO 1 ACSB01.06
7 Find the output of the following expression step by step by Remember CO 1 ACSB01.05
mentioning operator precedence and associativity in each step
17 – 8 / 4 * 2 + 3 - ++5
8 Write a C program to find the size of primary data types using size of Understand CO 1 ACSB01.06
operator?
9 Write a C program to calculate the area of a sphere where A = 4πr 2 by Understand CO 1 ACSB01.04
taking radius as input from the user?
10 Write a C program to read the temperature in Fahrenheit and convert it Understand CO 1 ACSB01.06
Into Celsius by using the formula C = (F − 32) × 5/9
11 Explain the special operators in C with example? Understand CO 1 ACSB01.05
12 Write a C program to find the area of a Circle and also draw a Understand CO 1 ACSB01.04
flowchart for it?
13 Write a C program to swap two numbers with and without using a Understand CO 1 ACSB01.06
third variable?
14 Write a C program to calculate the sum of N natural numbers without Understand CO 1 ACSB01.05
using a loop?
15 Draw a flowchart to find the factorial of a given number? Understand CO 1 ACSB01.06
16 Write a C program to find the volume of a Cone by reading the inputs Understand CO 1 ACSB01.05
radius and height from the user where V = πr2 (h /3)
17 The price of one kg of Rice is Rs. 40.75 and one kg of Dal is Rs. 72.50. Understand CO 1 ACSB01.04
Write a C program to get these values from the user and display the
prices as follows:
**** LIST OF ITEMS ****
*** Item Price ***
Rice Rs 40.75
Sugar Rs 72.50
18 Explain the various operators used in c programming and exemplify the Understand CO 1 ACSB01.04
use of ternary operator
19 Distance between two points (x1, y1) and (x2, y2) is governed by the Understand CO 1 ACSB01.04
formula D2 = (x2 – x1)2 + (y2 – y1)2
Write a C program to compute D given the coordinates of the points.
20 The total distance travelled by a vehicle in t seconds is given by Understand CO 1 ACSB01.04
distance = ut+ (at2)/2 Where u is the initial velocity (meters per
second), a is the acceleration (meters per second).
Write a C program to calculate the distance travelled, given the
values of u and a.
Part - C (Problem Solving and Critical Thinking Questions)
1 What does the following statement do, justify your answer? x = x |1 << Understand CO 1 ACSB01.05
n;
i. Sets x as2n
ii. Sets (n+1)thbit ofx
iii. Toggles (n+1)thbit ofx
iv. Unsets (n+1)thbit ofx
2 #include Understand CO 1 ACSB01.05
<stdio.h>
int
main(voi
d)
{
int a = 1; int b = 0;
b = a++ + a++; printf("%d %d",a,b); return 0;
}
i. 36
ii. Compiler Dependent
iii. 3 4
iv. 3 3
3 What is the output of following program? Understand CO 1 ACSB01.05
int main()
{
int a = 1; int b = 1;
int c = a || --b;
int d = a-- && --b;
printf("a = %d, b = %d, c = %d, d = %d", a,
b, c, d); return 0;
}
4 Predict the output of the below program: Understand CO 1 ACSB01.06
int main()
{
printf("%d", 1 << 2 + 3 << 4);
return 0;
}
5 Predict the output of following program? Understand CO 1 ACSB01.06
int main()
{
int x = 10; int y = 20;
x += y += 10;
printf (" %d
%d", x, y);
return 0;
}
6 Predict the output of following program? Understand CO 1 ACSB01.05
int main()
{
int a = 0; int b;
a = (a == (a == 1));
printf(
"%d",
a);
return
0;
}
7 Predict the output of following program? Understand CO 1 ACSB01.06
int main()
{
int y = 0;
int x = (~y == 1); printf("%d", x);
return 0;
}
8 Predict the output of following program? Understand CO 1 ACSB01.06
int main()
{
int a = 2,b = 5; a =a^b;
b =b^a;
printf("%d
%d",a,b);
return0;
}
9 What is the output of the program? Understand CO 1 ACSB01.06
int main()
{int x = 10, y = 20, z = 5, i; i = x
< y < z;
printf("%d\n", i);
return 0;
10 What is the output of the program Understand CO 1 ACSB01.04
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}printf("% d\n", X);
Return 0;
}
MODULE - II
CONTROL STRUCTURES
Part - A (Short Answer Questions)
1 What is a control structure? List out their types. Understand CO 2 ACSB01.07
2 Write a C program to check whether number is Prime or Not Understand CO 2 ACSB01.07
3 What is the difference between while loop and do-while loop Understand CO 2 ACSB01.07
4 Write a C program to check whether a number is positive or negative. Understand CO 2 ACSB01.07
5 Find the output of the following code? Understand CO 2 ACSB01.07
int main()
{
int i = 1;
for(; i< 4; i++);
printf("%d", i); return 0;
}
6 What is nested for and write the syntax of nested for loop. Understand CO 2 ACSB01.07
7 Find the output of the following code? Understand CO 2 ACSB01.07
int main()
{
int a;
for(a = 5; --a;)
printf("\n%d", a); return 0;
}
8 State the difference between entry controlled and exit controlled loop Remember CO 2 ACSB01.07
with example?
9 Write the usage of break and continue statement with example? Remember CO 2 ACSB01.07
10 Find the output of the following code? Understand CO 2 ACSB01.07
int main()
{
int a = 1, b = 2, c = 3, d =
4, e; if(e= (a & b | c ^ d))
printf("%d", e); return 0;
}
11 Find the output of the following code? Understand CO 2 ACSB01.07
int main()
{
int a=1,b=2,c=3,d=4; if (d > c)
if (c > b)
printf("%d %d", d, c); else if (c > a)
printf("%d %d", c, d);
if (c > a)
if (b < a)
printf("%d %d", c, a); else if (b < c)
printf("%d %d", b, c);
}
12 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
int choice = 3;
switch(choice)
{
default: printf("default");
case 1: printf("choice 1");break;
case 2: printf("choice 2");break;
}
}
13 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
char c = 125; do
printf("\n%d", c); while(c++);
}
14 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
for(;;)
{
printf("%d", 10);
}
}
15 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
printf("hi!"); if (!0)
printf("bye");
}
16 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
int a =1; if(a)
printf("test"); else ; printf("again");
}
17 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
int i =1;
if(i++, ++i, i--, --i)
printf(“%d\n”, i);
}
18 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
float i;
for(i = 0.1;i < 0.4; i += 0.1)
printf("%.1f\n", i);
}
19 Explain with example switch case execution process with and without Understand CO 2 ACSB01.07
break statement?
20 Find the output of the following code? Understand CO 2 ACSB01.07
void main()
{
int i = 3;
for(i--; i< 7; i = 7)
printf("%d", i++);
}
Part - B (Long Answer Questions)
1 Compare and Contrast while and do while loop? Write a C program to Remember CO 2 ACSB01.07
print the odd numbers from X to Y using do while loop?
2 An electric power distribution company charges domestic consumers Understand CO 2 ACSB01.07
as follows:
Consumption Units Rate ofcharge
0-20 Rs 0.50 perunit
201-400 Rs 100 + Rs0.65 per unit excessof200
401-600 Rs 230 plus 0.80 per unit excessof400
601andabove Rs 390 plus Rs 1.00 per unit excess
of600 Write a C program that reads the customer number and
power consumed and print amount to be paid by the customer
(Use else-if ladder)
3 Write a C program to display the traffic control signal lights based on Understand CO 2 ACSB01.07
the following.
i. If user entered character is R or r then print RED Light
Please STOP.
ii. If user entered character is Y or y then print
YELLOW Light Please Check and Go.
iii. If user entered character is G or g then print GREEN Light
Please GO.
iv. If user entered some other character then print THERE IS
NOSIGNAL POINT.
4 Admission to a professional course is subject to the following Understand CO 2 ACSB01.07
conditions:
i. Marks in Mathematics >=60
ii. Marks in Physics >= 50 Marks in Chemistry >=40
iii. Total in all three subjects >=200
iv. Total in Mathematics and Physics >=150
Given the marks in the three subjects, Write a C program to process
the application to list the eligible candidates.
5 Write a C program to compute the real roots of a quadratic equation Understand CO 2 ACSB01.07
ax2 + bx+ c = 0. The program should request for the values of the
constants a, b and c and print the values of x1 and x2.
Use the following rules:
i. No solution, if both a and b are zero There is only one root, ifa=0
ii. There are no real roots, if b2 - 4ac is negative
Otherwise, there are two real roots
Write a C program to test all the above conditions.
6 Write a program that counts from one to ten, prints the values on a Understand CO 2 ACSB01.07
separate line for each, and includes a message of your choice when the
count is 3 and a different message when the count is 7.
7 Write a C program to calculate commission for the input value of Understand CO 2 ACSB01.07
sales amount. Commission is calculated as per the following rules:
i. Commission is nil for sales amount Rs5000/.
ii. Commission is 2% for sales when sales amount is greater than
5000and less than equal to10000.
iii. Commission is 5% for sales amount greater than10000.
8 A character is entered through keyboard. Write a C program to Understand CO 2 ACSB01.07
determine whether the character entered is a capital letter, a small case
letter, a digit or a special symbol using if-else and switch case. The
following table shows the range of ASCII values for various
characters.
Characters ASC
i. x = 3, y = 4, z =2
ii. x = 6, y = 5, z =3
iii. x = 6, y = 3, z =5
iv. iv. x = 5, y = 4, z =5
8 Predict the output of the following: Understand CO 2 ACSB01.07
int main()
{
int i;
goto LOOP;
for(i = 0 ; i< 10 ; i++)
{
printf("IARE\n"); LOOP:break;
}
return 0;
}
9 Predict the output of the following: Understand CO 2 ACSB01.07
int main()
{
unsigned short int i = 65000; while(i++ != 0);
printf("ans : %d", i); return 0;
}
10 Predict the output of the following: Understand CO 2 ACSB01.07
#include<stdio.h>
int main()
{
int i = 65; char j='A'; while(i< j);
printf(" %d", (i ^ j )<< 2); return 0;
}
MODULE – III
ARRAYS AND FUNCTIONS
Part - A (Short Answer Questions)
1 What is an array and write the syntax to declare an array. Remember CO 3 ACSB01.08
2 State which of the following multi-dimensional array declaration is Understand CO 3 ACSB01.08
correct for realizing a 2x3 matrix?
int m[2][3];
int m[3][2];
int m[3],m[2];
3 Find the output of the following code? Understand CO 3 ACSB01.08
void main(){
int a[3][2] = {10, 20, 30, 40, 50, 60};
printf("%d", a[0][4]);
}
4 Find the output of the following code? Understand CO 3 ACSB01.09
void main()
{
char s1[] = "jaihind"; char s2[] ="jaipur"; int x;
x =strncmp(s1,s2,3); printf("x = %d", x);
}
5 Find the output of the following code? Understand CO 3 ACSB01.09
void main()
{
char s1[] = "NEW DELHI"; char s2[] ="BANGALORE";
strncpy(s1,s2,4); printf("%s", s1);
}
6 Identify which of the following is used to Remember CO 3 ACSB01.08
represent the end of a string?
i. Blankspace
ii. Nullcharacter
iii. Newlinecharacter
iv. Last element of thestring
7 Identify the string function used to find the sub- string in the main Remember CO 3 ACSB01.09
string and also write it‟s syntax?
8 Find the output of the following code? Understand CO 3 ACSB01.09
void main()
{
char s1[] = "NEW DELHI";
char s2[] ="NEW";
printf("%d",strstr(s1,s2));
}
9 Find the output of the following code? Understand CO 3 ACSB01.08
void main()
{
int a[4][3];
printf("%d",sizeof(a));
}
10 Write the syntax for strcat() and strncat() with example? Remember CO 3 ACSB01.09
11 Write a C program to read a lowercase string and convert it into Understand CO 3 ACSB01.09
uppercase.
12 Write a C program to accept two strings and compare them. It should Understand CO 3 ACSB01.09
print
whether both are equal or first string is greater than the second or the
first string is less than the second string.
13 Write a C program to read N unsorted integers and sort them in Understand CO 3 ACSB01.08
ascending order.
14 Explain the following string handling functions with example: Understand CO 3 ACSB01.09
i. strcpy()
ii. strcat()
iii. strrev()
iv. strcmp()
v. strupr()
15 Write a C program to add a string at the end of another string and Understand CO 3 ACSB01.09
display the output.
char a[20] = “hello”; char b[10] = “World”;
Output:
“HelloWorld”
16 Write C programs that uses both recursive and non-recursive Understand CO 3 ACSB01.10
functions:
a. Find the sum of n natural numbers
b. Find the factorial of a given number
17 Write a C program that uses functions to do the following: Understand CO 3 ACSB01.11
a. Convert decimal number to binary number
b. Convert binary number to decimal number
18 Write C programs that uses both recursive and non-recursive Understand CO 3 ACSB01.10
functions:
a. Find the Nth Fibonacci number
b. Find the reverse of a number
19 Write a C program that uses functions to do the following: Understand CO 3 ACSB01.10
a. Convert a Roman letter into its decimal equivalent.
b. Find 2‟s complement of a binary number.
20 Write a user defined function which takes an array of sorted integers Understand CO 3 ACSB01.10
and returns the median value?
[Hint: For odd set of integers there will be a single median and for
even set of integers, there will be two middle values and median is
the average of the two middle values]
Part - C (Problem Solving and Critical Thinking Questions)
1 Predict the output of the following code? Understand CO 3 ACSB01.08
int main()
{
int arr1[]={97, 98, 99, 100, 101, 102, 103, 104, 105};
int i=0; while(i++ < 5)
printf("\n %c ", arr1[i++]); return 0;
}
2 Find the output of the following code? Understand CO 3 ACSB01.08
void main()
{
int a[3] = {10, 20, 30};
a[2] = 2;
a[2 -2] = 2;
printf("%d\t%d\t%d", a[0], a[1], a[2]);
}
3 Find the output of the following code? Understand CO 3 ACSB01.08
void main()
{
char a[5] = "IARE"; int i =0;
while(a[i])
printf("%s\n", (a + i++)); }
4 Find error if any: Understand CO 3 ACSB01.08
Void main()
{
int x =5;
int a[x]; a[1] = 12;
printf(“%d”, a[1]);
}
5 Find the output of the following code? Understand CO 3 ACSB01.08
void main()
{
int x[5] = {1, 2, 3, 4, 5};
int i;
for(i = 0; i< 20; i++) printf(“%d\n”, x[i]);
}