Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSD 101 ENDSEMS 2015 C language, Exams of Programming Languages

CSD 101 ENDSEMS 2017, High chance of question getting repeated or getting the similar type of questions, C language.

Typology: Exams

2015/2016

Available from 08/10/2021

meetendra-singh
meetendra-singh 🇮🇳

17 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programme: B. Tech Discipline: Computer Science and Engineering
Exam: End Semester Year: 2016-2017
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)
1. In ________________ method, address of the variable is passed by the calling function to the called function.
2. The C language was originally developed from ____________________ language.
3. The standard mathematical functions are included in the ______________ header file.
4. An immediate exit from the loop can be achieved by a _________________ statement.
5. The function int func(); takes _______________ (how many?) arguments.
6. A variable can be made constant by declaring it with the qualifier ______________ at the time of initialization.
7. A computer program that converts assembly language programs to machine language programs is called
______________.
8. The _________________ standard library function is used to obtain data from the keyboard.
9. A ___________________ is a graphical representation of an algorithm.
10. Keyword _______________ is used in a function header to indicate that a function does not return a value or to
indicate that a function contains no parameters.
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)
pf3
pf4

Partial preview of the text

Download CSD 101 ENDSEMS 2015 C language and more Exams Programming Languages in PDF only on Docsity!

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)

  1. In ________________ method, address of the variable is passed by the calling function to the called function.
  2. The C language was originally developed from ____________________ language.
  3. The standard mathematical functions are included in the ______________ header file.
  4. An immediate exit from the loop can be achieved by a _________________ statement.
  5. The function int func(); takes _______________ (how many?) arguments.
  6. A variable can be made constant by declaring it with the qualifier ______________ at the time of initialization.
  7. A computer program that converts assembly language programs to machine language programs is called ______________.
  8. The _________________ standard library function is used to obtain data from the keyboard.
  9. A ___________________ is a graphical representation of an algorithm.
  10. Keyword _______________ is used in a function header to indicate that a function does not return a value or to indicate that a function contains no parameters.

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)

  1. In C, upper and lower cases letter are same.
  2. #define lines should end with a semicolon.
  3. <stdio.h> refers to standard i/o header file.
  4. <stdio.h> contains mathematical functions.
  5. The statement #define X = 5.5 is invalid.
  6. The statement #define N 5, M 25 is valid.
  7. The assignment statement a = = b = c = 0; is not a valid C statement.
  8. “%s” format can be used to read/print a string.
  9. “%u” format is used to read/print an unsigned decimal integer.
  10. If statement represents the evaluated result in the form of either non-zero or zero values.
  11. strcpy(s1, s2) function copies s1 to s2.
  12. strcat(s1, s2) concatenates s2 at the end of s1.

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]); }

Ques.12 Complete the following code so that the function will return x

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); }