Mid Sem Sample Paper

##This is just sample paper. The actual marking scheme for the mid sems might vary but this will give you a general idea of the Mid Semester CP exam.Try solving the paper within 1hr15mins. Best Of Luck!


Q1.Solve the following . (1 mark each.)                                                                                  [10marks]


1.What error would the following program give on compilation?

f(int a,int b)

{

int a;

a=20;

return a;

}

  1. Missing parentheses in return statement.
  2. The function should be defined as int f(int a, int b)
  3. Redeclaration  of a.
  4. None of the above.

2.Consider the list of words given below.

a. break   b.else    c.long

Select the correct statement.

  1. Only a is a keyword in C
  2. Only a and b are keywords in C
  3. None of the above are keywords in C.
  4. All the above are keywords in C.

3.What would be the output of the following program if the starting address  is 65486?

main()

{

int arr[]={12,15,55,42,1}

printf(“%u %u”,arr,&arr);

}


4.What will be the output of the function if it is called as xyz(‘E’)?

What does the function do?

int xyz(int c)

{

if(c>=’A’ && c<=’Z’)

return c+’a’-‘A’;

else

return C;

}


5.Consider  following snippet.

int i=1,sum=0,sum2;

while(i<10)

{

sum2=0;

while(i<=4)

{

sum2+=i;

i++;

}

sum+=sum2;

i++;

}

printf(“%d”,sum);

what will the output produced?


6. #include<stdio.h>

int main()

{

float a=5,b=2;

int c,d;

c=a%b;

d=a/2;

printf(“%d”,d);

return 0;

}

What will be the output?


7.Which keyword is used to take control of the beginning of the loop?


8.Consider  the following snippet.

for(i=1;i<=10;i++){

if(i>4) break; else continue;

printf(“%d”,i);

}

How many times will the printf statement in the loop be executed?


9.#include<stdio.h>

int main()

{

int sub[50],I;

for(i=0;i<=48;i++);

{

sub[i]=i;

printf(“%d”,sub[i]);

}

return 0;

}

What will be the output of the above program?


10.The expression num[27] designates twenty-eighth element to an array.[true/false]?


Q2a.Write a program that abbreviates the first and middle name of an entered name without changing the last name.                                                                                                                         [5marks]

-OR-

Q2a.One way to find the GCD of two numbers is as given below.

If 30 and 25 are two entered numbers then subtract the smaller number form the larger number.

The subtraction is 5 which is less than the smaller number amongst the entered  numbers. So subtract 5 from 25 till the value of the subtraction becomes equal to the number being subtracted, here, 5.

(20-5=15>5 : 15-5=10>5; 10-5=5) Therefore 5 is the gcd of the two numbers.         [5marks]


Q2b. Write a program to merge two integer arrays such that the final array has no duplicate elements.

Take a sample input as a:{1,1,2,2}, b:{2,3,2} and hand run(dry run) your program.

[For eg, a:{1,1,2,2,3,3} b:{2,2,4,4,1}

When the final array is printed then the output must be  {1,2,3,4}]                            [10marks]


Q3.Write a program that gets executed as follows:

>>The user is asked to enter a number.

>>If n%3=0 then “www.decodingc.wordpress.com” will get printed.

>>If n%3=1 then “College of  Engineering Pune” will get printed.

>>If n%3=2 then “Strength Truth Endurance” will get printed.

CONDITONS:Donot use if-else Statement or switch case statement.                                                                       [5 marks]


Leave a comment