


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
CSD 101 ENDSEMS 2017, High chance of question getting repeated or getting the similar type of questions, C language.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Programme: B. Tech Discipline: Computer Science and Engineering Exam: End Semester Year: 2016- Course Code: CSD101 Course Title: Introduction to Computing & Programming Date: December 03, 2016 Time: 9.30 AM - 12.30 PM Max. Marks: 100
Ques.1 What, if anything, prints when each of the following C statements is performed? If the statement contains an error, describe the error and indicate how to correct it. Assume the following variable definitions: (2*5 = 10 Marks)
char s1[ 50 ] = "jack", s2[ 50 ] = "jill", s3[ 50 ];
a) printf( "%c%s", toupper( s1[ 0 ] ), &s1[ 1 ] ); b) printf( "%s", strcpy( s3, s2 ) ); c) printf( "%s", strcat( strcat( strcpy( s3, s1 ), " and " ), s2 ) ); d) printf( "%u", strlen( s1 ) + strlen( s2 ) ); e) printf( "%u", strlen( s3 ) );
Ques.2 Fill in the following blanks : (1*10 = 10 Marks)
Ques.3 Convert the following numbers from one base to another. (The intermediate steps must be shown). (1*5 = 5 Marks)
(i) (1100001) 2 = to decimal (ii) (100100.1010) 2 = to octal (iii) (A029) 16 = to decimal (iv) (BABA) 16 = to binary (v) (742) 10 = to binary
Ques.4 What is the difference between constant to pointer and pointer to constant? Explain by giving proper examples for each. Give 3 points of difference including example. (6 Marks)
Ques.5 State whether the following statements are True/False : (1*12 = 12 Marks)
Ques.6 Find the output for the following program segments: (12 Marks)
(i) #include "stdio.h" #include "string.h" void main() { int i=0; for( ; i<=2; ) printf(" %d\n", ++i); }
(ii) void main() { printf("%d", sizeof(5.2)); }
(iii) void main() { int i = 10; static int x = i; if(x == i) printf("Equal"); else if(x > i) printf("Greater than"); else printf("Less than"); } (a) Equal (b) Greater than (c) Less than (d) Compiler Error (e) None of these
(iv) void main() { int num = 5, *ptr = # printf(โ%d\nโ, *&num); printf(โ%d\nโ, &&num);
printf(โ%d\nโ, *&ptr); printf(โ%d\nโ, &ptr); printf(โ%d\nโ, &&ptr); }
(v) void main() { int num = 5, ptr = # printf(โ%d\n%dโ, num, (ptr)--); }
(vi) void main() { int arr[ ] = {1, 2, 3, 4, 5}, i; for(i=0; i<10; i++) *(arr + i) = i; printf(โ%dโ, arr[3]); }
(vii) #include<stdio.h> void func(int (parr)[3]); void main() { int arr[2][3] = {1, 2, 3, 4, 5, 6}; func(arr); func(arr+1); } void func(int (parr)[3]) { int i; for(i=0; i<2; i++) printf("%d\n", (*parr)[i]); }
n
. (2 Marks)
int foo(int x, int n) { int val = 1; if (n > 0) { if (n % 2 == 1) val *= x; val *= foo( ___________ , ______________ ); } return val; }
Ques13. Rewrite the following code without using โ break โ statement so that the functionality of the code should not get changed: (5 Marks)
#include<stdio.h> void main() { int num, sum = 0; while(1) { printf(โ\nEnter any number. Enter 999 to stop:โ); scanf(โ%dโ, &num); if(num == 999) break; sum += num; } printf(โ\n SUM = %d\nโ, sum); }