[go: up one dir, main page]

0% found this document useful (0 votes)
8 views7 pages

4

This document outlines the examination paper for the Odd Semester End Term Examination for the B.Tech program, specifically for the course 'Problem Solving Using Computers'. It includes various sections with questions on flowcharts, programming outputs, true/false statements, and C programming tasks, along with their respective marks allocation. The paper is structured to assess students' understanding of computer programming concepts and problem-solving skills.

Uploaded by

nevaidhyasingh
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)
8 views7 pages

4

This document outlines the examination paper for the Odd Semester End Term Examination for the B.Tech program, specifically for the course 'Problem Solving Using Computers'. It includes various sections with questions on flowcharts, programming outputs, true/false statements, and C programming tasks, along with their respective marks allocation. The paper is structured to assess students' understanding of computer programming concepts and problem-solving skills.

Uploaded by

nevaidhyasingh
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
You are on page 1/ 7

Name:

Enrolment No:

Odd Semester End Term Examination, April-May 2024


Department of First Year
B.Tech – All Branches
Course Code: CS1002 Course: Problem Solving Using Computers Semester: I
Time: 03 hrs. Max. Marks: 80
Instructions: All questions are compulsory.
Missing data, if any, may be assumed suitably.
Calculator is Not allowed.
SECTION A
S.No. Marks CO
Q A1 Draw a flowchart for “Withdrawal of money from ATM, by taking amount from user
and checking balance, if no sufficient amount no transactions”.

Solution:
1.
2 CO1

Marks Scheme: 2
Q A2 Predict the output of the following program:
# include<stdio.h>
2. int main( )
{
int x = 3 ;
float y = 3.0 ;
if ( x == y ) 2 CO2
printf ( "x and y are equal\n" ) ;
else
printf ( "x and y are not equal\n" ) ;
return 0 ;
}
Sol: x and y are equal Marks Scheme: 2
Q A3 Fill in the blanks in the following statements:
(i) ……. is the process of arranging elements of an array in order.
(ii) The parameters used in a function call are called ………… 2 CO3
Sol: (i) Sort/Sorting
3. (ii)Actual Arguments Marks Scheme: 1+1
Q A4 State whether the following statements are True/False
(i) Unary increment and decrement operators have greater precedence than
dereference operator. 2 CO4
4. (ii) Pointers can be used to make a function return more than one value
simultaneously in an indirect manner.

Page 1 of 7
Sol:
(i) True
(ii) True Marks Scheme: 1+1
Q A5 Predict the output of the following program:
#include<stdio.h>
int main()
{
5. int x = 10; // integer x
char y = 'a'; // character c 2 CO5
x = x + y;
float z = x + 1.0;
printf("x = %d, z = %f", x, z);
return 0;
}
Sol: x=107, z=108.0000 Marks Scheme:1+1
SECTION B
Q B1 What is meant by stored program concept? Draw a block diagram of Von Neuman
architecture computer, with its major components showing the transfer of data
amongst its units.

Sol: The stored program concept means that data and instructions are both logically
the same and can both be stored in memory. The von Neumann architecture is built
around this principle.
6 CO1

6.

Marks Scheme: 2+4


Q B2 Match the following:
(a) \n (i) Literal
(b) 3.145 (ii) Identifier
(c) -6513 (iii) Character constant
(d) ’D’ (iv) Escape sequence
7. (e) 4.25e-3 (v) Input function
(f) main( ) (vi) Function
(g) %f, %d, %c (vii) Integer constant 6 CO2
(h) scanf( ) (viii)Address of operator
(i) Constant (ix) Output function
(j) Variable (x) Format specifier
(k) & (xi) Exponential form
(l) printf( ) (xii) Real constant

Page 2 of 7
Sol:
(a) ……(iv) (e) ……(xi) (i) ……(i)
(b) ……(xii) (f) ……(vi) (j) ……(ii)
(c) ……(vii) (g) ……(x) (k) ……(viii)
(d) ……(iii) (h) ……(v) (l) ……(ix)

Marks Scheme: Each Question 0.5 X 12=6

Q B3 Write a C program which performs the following tasks sequentially.


a. Declare a string variable named ‘info’ with a capacity of 100.
b. Using input function read the string value as “Manipal University Jaipur”.
c. Print reverse of the string.
8. d. Convert the string in Upper Case and print it.
e. Determine the frequency of the character 'a' in the string and display the count
of it.
Marks Scheme: [0.5+0.5+1+2+2]
Sol: a. char info[100];
b. gets(info)// Enter String as Manipal University Jaipur
or char info[100]=”Manipal University Jaipur”;

c. int n = strlen(info); // String length n need to find for reverse of string


//More Formal
for(i=0;i<n/2;i++) #include <stdio.h>
#include <string.h>
{ #include <ctype.h>
temp=info[i]; int main() {
char info[100];
info[i]=info[n-i-1]; int length, i, count = 0;
info[n-i-1]=temp; // Input 6 CO3
printf("Enter a string: ");
} scanf("%s", info);
printf("\nReversed string is:“); // Print reverse of the string
length = strlen(info);
puts(info); printf("Reverse of the string: ");
for (i = length - 1; i >= 0; i--) {
printf("%c", info[i]);
d. }
int n = strlen(info); printf("\n");
for(i=0;i<n;i++) // Convert the string to upper case
{ printf("String in Upper Case: ");
if(info[i]>=97 && info[i]<=122) for (i = 0; info[i] != '\0'; i++) {
printf("%c", toupper(info[i]));
info[i]=info[i]-32; }
} printf("\n");
puts(info); // Determine the frequency of character 'a'
for (i = 0; info[i] != '\0'; i++) {
if (tolower(info[i]) == 'a') {
e. count++;
int count = 0; }
}
for (int i = 0; i < n; ++i) printf("Frequency of 'a' in the string: %d\n", count);
{ return 0;
if (info[i] == 'a') }
{
count++;
}
}
Q B4 Read the below statements of a given program and provide the solutions of asked
questions: 6 CO4
#include<stdio.h>
Page 3 of 7
9. int fun1(int *,int *);
void main()
{
int a=10,b=20,sum,z=5;
int *p,*q;
p=&a,q=&b;
z=fun1(p,q);
printf("x=%d y=%d p=%d q=%d\n",a,b,*p,*q);
printf("z=%d\n",z++);
}
int fun1(int *a,int *b)
{
*a=*a+*b;
*b=*a+*b;
int sum=*a+*b;
return sum;
}
(i) What value of x,y,p,q will be printed?
(ii) What value of z will be printed?
(iii) What value of sum will be printed?

Sol:
(i) X=30, y=50,p=30,q=50
(ii) Z=80
(iii) Z=80 Marks Scheme:2+2+2
Q B5 Write a program to calculate a bill for callings [without loops]. The conditions are
givenbelow:
Minimum Rs. 200 for up to 100 calls.
Plus, Rs. 0.60 per call for the next 50 calls. Marks Scheme: Each case 2
Plus, Rs. 0.50 per call for the next 50 calls.
Plus, Rs. 0.40 per call for any call beyond 200 calls
10. Sol: OR #include <stdio.h>
int main() { int i; float x=0;
#include <stdio.h> printf("Enter the Units consumed by customer: ");
int main() { scanf("%d",&i);
int i; switch(i)
float x=0; { case 1: printf("Electricity Bill is 200\n");break;
printf("Enter the Units consumed by customer: "); case 10: printf("Electricity Bill is 200\n");break;
scanf("%d",&i); case 100: printf("Electricity Bill is 200\n");break;
switch(i) case 101: x=200+(i-100)*0.6; printf("Electricity Bill %d =
{ %f\n",i,x);break;
case 1 ... 100: printf("Electricity Bill is= 200/- case 110: x=200+(i-100)*0.6; printf("Electricity Bill %d = 6 CO5
\n");break; %f\n",i,x);break;
case 101 ... 150: x=200+(i-100)*0.6; case 155: x=200+(50*0.6) )+(i-150)*0.5; printf("Electricity Bill %d =
printf("Electricity Bill %d = %f\n",i,x);break; %f\n",i,x);break;
case 151 ... 200: x=200+(50*0.6)+(i-150)*0.5; case 201: x=200+(50*0.6) + (50*0.5)+(i-200)*0.4; printf("Electricity
printf("Electricity Bill %d = %f\n",i,x);break; Bill %d = %f\n",i,x);break;
default : x=200+(50*0.6)+(50*0.5)+(i-200)*0.4; case 210: x=200+(50*0.6) + (50*0.5)+(i-200)*0.4; printf("Electricity
printf("Electricity Bill %d = %f\n",i,x); Bill %d = %f\n",i,x);break;
} case 400: x=200+(50*0.6) + (50*0.5)+(i-200)*0.4; printf("Electricity
return 0; Bill %d = %f\n",i,x);break;
} default : x=200+(50*0.6) + (50*0.5)+(i-200)*0.4; printf("Electricity
Bill %d = %f\n",i,x);
}
return 0;
OR }

Page 4 of 7
#include <stdio.h> int main() {
int calls; float bill = 0.0;
// Input number of calls
printf("Enter the number of calls: "); scanf("%d", &calls);
// Calculate bill
if (calls <= 100) {
bill = 200.0;
} else if (calls <= 150) {
bill = 200.0 + (calls - 100) * 0.60;
} else if (calls <= 200) {
bill = 200.0 + 50 * 0.60 + (calls - 150) * 0.50;
} else {
bill = 200.0 + 50 * 0.60 + 50 * 0.50 + (calls - 200) * 0.40;
}
// Print bill
printf("The total bill for %d calls is Rs. %.2f\n", calls, bill);
return 0;
}

SECTION-C (Analytical Based Questions)


Q C1 Write a C program to print following patterns using nested loops:
(i) (ii)
1 1
12 2 3
12 3 4 5 6
11. 1234 7 8 9 10
12345 Marks Scheme: 5+5
Sol: (ii)
#include <stdio.h>
int main()
(i)
{
#include <stdio.h>
int i,j,k,num=1,rows;
int main()
printf("Enter No. of Rows");
{
scanf("%d",&rows); // Here rows=4 in problem 10 CO3
int i,j;
for(i=1;i<=rows;i++) // Number of Rows printing
for(i=1;i<=5;i++)
{
{
for(j=rows-i;j>=1;j--) // Number of Spaces printing
for(j=1;j<=i;j++)
{
{ printf("%d ",j); }
printf(" ");
printf("\n");
}
}
for(k=1;k<=i;k++) // Values print in each row
}
{
printf("%d ",num);
num++;
}
printf("\n");
} // close of Outer Loop
} // close of main

Q C2 Evaluate the following expressions on integer values a = 10, b = 8, by keeping in


view of operator’s precedence relationship in this problem:
(i) Result=2*((a/5)+(4*(b-3))%(a+b-2))
(ii) Result=a<<2
(iii) Result= (a==10 + 15 && b < 10)
12. (iv) Result=((b=2)==a) 10 CO2
(v) Result=++a + b
Sol:
(i) 12
(ii) 40
(iii) 0
Page 5 of 7
(iv) 0
(v) 19
SECTION-D
Q D1 Write a C program to multiply two matrices (2D array) of MXN size matrix entered
by the user. The user enters the order of matrix and then its element, and similarly
input of the second matrix is entered. If the entered orders of two matrices are such
that they can’t be multiplied by each other, then error message is displayed on the
screen. Marks Scheme: 2+2+2+4

Sol: #include<stdio.h> #include<stdlib.h>


13.
int main(){ int i, j, m, n, p, q,k;
int a[10][10], b[10][10],c[10][10];
printf("enter dimension for a \n");
scanf("%d %d",&m,&n);
printf("\n enter dimension for b\n");
scanf("%d %d", &p,&q);
if(n!=p){
printf("not multiplicable \n");
exit(0); }
printf("enter elements for a \n");
for (i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
printf("\n enter elements for b\n"); 10 CO4
for(i=0;i<p;i++)
{ for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
}

for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
printf("\n The product matrix is \n");
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
printf("%d\t",c[i][j]);
printf("\n“);
}
}//close of main

Page 6 of 7
Q D2 Create a structure to specify students’ information as below:
Roll number, Name, Department, Course, Year of joining and DoB. Assume that there are
not more than 100 students in the college.
(i) Write a function to print names of all students who joined in a particular year.
14. (ii) Write a function to print the data of a student whose roll number is received by
the function. Marks Scheme: 4+3+3 #include <stdio.h> // More General Way to express
struct Student{
int roll;
char name[15];
Sol: char deptt[20];
char course[10];
int doj;
struct student struct DOB{
int dd;
{ int mm;
int roll; int yy;
}dob;
char name[10]; }st[100];
char dept[10]; void search_doj(int year,int n)
{
char course[10]; int i;
int doj; for(i=0;i<n;i++)
{
struct DOB { if(year==st[i].doj)
int dd; {
printf("%s\n",st[i].name);
int mm; }
int yy; }
}
}dob; void search_roll(int rol,int n)
}st[100]; {
int i;
for(i=0;i<n;i++)
(i) void search_doj(int year) {
if(rol==st[i].roll)
{ {
int i; printf("%d %s %s %s %d %d-%d-%d \n",st[i].roll, st[i].name,
st[i].deptt, st[i].course, st[i].doj, st[i].dob.dd,st[i].dob.mm, st[i].dob.yy);
for(i=0;i<100;i++)
{ }
} 10
if(year==st[i].doj) }
void main()
[4+3+3 CO5
{ { ]
int n,i, yr,rl;
printf("%s\n",st[i].name); printf("How many students?");
}//end of if scanf("%d",&n);
for(i=0;i<n;i++)
}//End of loop {
}//End of Function printf("Enter the detail of the student no %d...\n",i+1);
printf("Enter roll no:");
(ii)void search_roll(int roll) scanf("%d",&st[i].roll);
{ getchar();
printf("Enter name:");
int i; gets(st[i].name);
for(i=0;i<100;i++) printf("Enter department:");
gets(st[i].deptt);
{ printf("Enter course name:");
if(roll==st[i].roll) gets(st[i].course);
printf("Enter joining year:");
{ printf("%d%s%s%s%d%d%d%d\n", scanf("%d",&st[i].doj);
st[i].roll,st[i].name,st[i].dept),st[i].course, printf("Enter date of birth:");
scanf("%d",&st[i].dob.dd);
st[i].doj,st[i].dob.dd,st[i].dob.mm,st[i].dob.yy); printf("Enter month of birth:");
}//end of if scanf("%d",&st[i].dob.mm);
printf("Enter year of birth:");
}//End of loop scanf("%d",&st[i].dob.yy);
}//End of Function }
printf("Enter the year to search:");
scanf("%d",&yr); search_doj(yr,n);
printf("Enter the roll no to search:");
scanf("%d",&rl); search_roll(rl,n);
}

Page 7 of 7

You might also like