4
4
Enrolment No:
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.
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)
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;
}
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