Btech 2020 2 Sem Cp-Ii Sessional I

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

DHARMSINH DESAI UNIVERSITY, NADIAD

FACULTY OF TECHNOLOGY
B.TECH. SEMESTER II [CE/EC/IT]
SUBJECT: C Programming II (CT215)
Examination : First Sessional Seat No. :
Date : 05/02/2020 Day : Wednesday
Time : 03:45 to 05:00 Max. Marks : 36
INSTRUCTIONS:
1. Figures to the right indicate maximum marks for that question.
2. The symbols used carry their usual meanings.
3. Assume suitable data, if required & mention them clearly.
4. Draw neat sketches wherever necessary.
Q.1 Do as directed. [12]
(a) If an array is declared as double arr[ ]={10,20,30,40,50}; then what is the output of [2]
following C statement? printf(“%d \t %d \n”, sizeof(arr[2]), sizeof(arr));
(b) Write the output for following C code. [2]
#include<stdio.h> int func1(int k)
int func1(int); {
void main() k=k+1;
{ int n=20; return k;
n = func1(n=func1(n=func1(n))); }
printf("n=%d\n", n);
}
(c) Write the different ways of reading a string from user. [2]
(d) Write a logic to compute pow(x,y) using recursive function. (i.e. pow(x,y) = x^y) [2]
(e) Find out an error if any, correct it and write output for the following code. [4]
(I) #include<stdio.h> (II) #include<stdio.h>
#include<string.h> void main()
void main() { int p=100, q=20;
{char s1[20]="university"; { int p=10, r=2;
char s2[10]={'c','o','l','l','e','g','e','\0'}; { int p=25, s=p*3;
strncpy(s1,s2,4); printf("%d \n",s);
printf("%s",s1); }
strcpy(s1,s2); }
printf("\n%s",s1); printf("%d \n",r);
} }
Q-2 Answer the following questions. (attempt any two) [12]
(a) WAP which will read two N x N matrix A and B from the user and compute the result for [6]
the following expression.
Res[N][N] = 5 * A [N][N] – A[N][N] * B[N][N]
(b) The character array for Master_List[5][10]= {“Admin”,“Jack”,“Joseph”,“Carl”,“Tom”} is [6]
available. Write a program which asks user to enter a username. If the username entered is
one of the names in the Master_List then the user is allowed to do swapping of two integer
numbers and display the output. Otherwise, an error message is displayed.
(c) Write a menu driven program using function to calculate following [6]
i) Area of a Rectangle
ii) Area of a Circle
iii) Area of Triangle
Based on the input from the user, area of a particular shape will be calculated and result will
be displayed. ( use the category: Function with argument and without return value)
Q.3 Answer the following questions. [12]
(a) Answer the following. [4]
(1)What happens when an array with specified size is assigned [2]
(i) with values fewer than the specified size
(ii) with values more than the specified size
(2) What is multi-dimensional array? Give an example. [2]
(b) Write a program to copy the last n characters of string 2 at the end of string 1. Also convert [4]
the lower case letters to upper case letters while copying.
(c) Write a program which contains a Date function with three integer parameters as Date(int [4]
day, int month, int year). The function will print the date in the following format 5-
February-2020. The program should also validate for date and month input.(i.e. day input
should be in range from 1 to 31 and month input should be in 1 to 12. ) otherwise display an
error message.
OR
Q.3 Answer the following questions. [12]
(a) Write a program to read n floating point numbers in an array. Also update an array to insert a [4]
new element at given position using function. (Pass array as an argument to function).
(b) Write a program to remove all the characters in a String except the alphabets. (i.e. Input [4]
String=”c-p2'r-o@gramm84in./g” then the Output String=”cprogramming”)
(c) Explain the storage classes in C with example. [4]
page 1 of 1

You might also like