











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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
CSD 101 ENDSEMS 2017, High chance of question getting repeated or getting similar type of questions
Typology: Exams
1 / 19
This page cannot be seen from the preview
Don't miss anything!
Programme: B. Tech Discipline: Computer Science and Engineering Exam: End Semester Year: 2017- Course Code: CSD101 Course Title: Introduction to Computing & Programming Date: December 03, 2017 Time: 9.30 AM - 12.30 PM Max. Marks: 100 Ques.1 Do each of the following: (18 = 8 Marks) a)* Write the function header for a function called exchange that takes two pointers to floating-point numbers x and y as parameters and does not return a value. b) Write the function prototype for the function in part (a). c) Write the function header for a function called evaluate that returns an integer and that takes as parameters integer x and a pointer to function poly. Function poly takes an integer parameter and returns an integer. d) Write the function prototype for the function in part (c). e) Write the function header for function zero which takes a long integer array parameter bigIntegers and does not return a value. f) Write the function prototype for the function in part (e). g) Write the function header for function add1AndSum which takes an integer array parameter oneTooSmall and returns an integer. h) Write the function prototype for the function described in part (g). Ques.2 How many bytes in memory would be occupied by the following array of pointers to strings? How many bytes would be required to store the same strings, if they are stored in a two-dimensional character array? (2 Marks) Char mess[ ] = { “Hammer and Tongs”, “Tooth and Nail”, “Spit and Polish”, “ You and C” }; Ques.3 Can an array of pointers to strings be used to collect strings from the keyboard? If not, why? (2 Marks) Ques.4 Show two different methods of initializing character array vowel with the string of vowels, “AEIOU”. (2 Marks) Ques.5 State whether the following statements are True/False : (110 = 10 Marks)
1. When the printf function is called it always begins printing at the beginning of a new line. 2. A string when read using scanf() needs an ampersand character. 3. Comments are instructions that cause some action to take place. 4. If S1 and S2 are two strings, then concatenation operation produces a string which contains characters of S2 followed by the characters of S1. 5. A function cannot be defined inside another function. 6. If return type for a function is not specified, it defaults to int. 7. C considers the variables number and NuMbEr to be identical. 8. A string Hello World can be read using scanf. 9. To ensure that a character is uppercase, the toupper conversion function is used. 10. Are the three declarations char **apple, char *apple[ ], and char apple[ ][ ] same? Ques.6 Write a C program to find the length of a given string. (Do not use “strlen” function) (2 Marks) Ques.7 Write a C program to copy the contents of a given string into another string. (Do not use “strcpy” function) (2 Marks)
Ques.8 Find the output for the following program segments: (1 * 8 = 8 Marks) a) #include<stdio.h> void main() { int const a = 5; a++; printf(“%d”, a); } b) #include<stdio.h> void main() { const int a = 5; a++; printf(“%d”, a); } c) #include<stdio.h> void main() { char s[ ]="hello", t[ ]="hello"; if(s = = t) printf("equal strings"); else printf("No Output"); } d) #include<stdio.h> void main() { int x = ~1; printf(“%d”, x); } e) #include<stdio.h> void f() { static int i; ++i; printf("%d", i); } void main() { f(); f(); f(); } f) #include<stdio.h> void main() { register int x = 5; int *p; p=&x; x++; printf("%d", p); } i) Compiler Error ii) 5 iii) 6 iv) Garbage Value g) #include<stdio.h> void f() { printf("Hello\n"); } void main() { ; } i) No output ii) Error, as the function is not called iii) Error, as the function is defined without its declaration iv) Error, as the main() function is left empty h) #include<stdio.h> void main() { int i = 13, j = 60; i ^= j; j ^= i; i ^= j; printf("%d %d", i, j); } Ques.9 Fill in the following blanks : (112 = 12 Marks)
1. The bits in the result of an expression using the _______________ operator are set to 1 if the corresponding bits in each operand are set to 1. Otherwise, the bits are set to zero. 2. The _______________ operator returns the location in memory where its operand is stored. 3. To simulate call by reference when passing a non-array variable to a function, it is necessary to pass the _______________ of the variable to the function. 4. The conversion specifiers _________ and __________ are used to print strings and characters, respectively.
Ques.17 What is the default value of local and global variables? (2 Marks) Ques.18 Convert the following into its given equivalent codes. Show steps of conversion also. (4 Marks)
Q1. (a) void exchange(float *x, float *y) (b) void exchange(float , float ); (c) int evaluate( int x, int (poly)(int a)) (d) int evaluate( int , int ()(int )); (e) void zero( long int bigIntegers[ ]) (f) void zero( long int [ ]); (g) int add1AndSum(int oneTooSmall[ ]) (h) int add1AndSum(int [ ]); Q2. 58 Bytes 68 Bytes to store in a two-dimensional array. Q3. No, we can not collect strings from the keyboard in an array of pointers to strings. The reason is that when we initialize such array pf pointers, then at the time of initialization, the pointers will start pointing to some garbage location. Those uninitialized pointers are not actually pointing anywhere. That array is filled with garbage, which means that all those pointers could be pointing anywhere at all, most likely to memory that doesn't belong to you and hence that you have not been granted access to. Q4. (i) char vowel[ ] = “AEIOU”; (ii) char *vowel = “AEIOU”; Q5. 1. False
Q9. 1. Bitwise AND
Q13. It will compare 2 strings and return 1 if they are same else return 0. Q14. A double pointer is a pointer variable that holds the address of another pointer variable. For Example: int a = 10; int *j = &i; int *k = &j; Here, double pointer k stores of another pointer variable j. Q15. American Standard Code for Information Interchange. Q16. strcat( ) Q17. Local – Garbage Value Global – zero ( 0 ) Q18. (i) (84) 10 = (1110) 4 (ii) (2C9) 16 = (713) 10 (iii) (101010) 2 = (52) 8 (iv) (3674) 8 = (011110111100) 2 Q19. #include<stdio.h> void main() { int n, i, j, temp, pos; printf("Enter the size of array\n"); scanf("%d", &n); int arr[n]; printf("Enter array elements\n"); for(i=0; i<n; i++) scanf("%d", &arr[i]); printf("Array before Sorting\n"); for(i=0; i<n; i++) printf("%d\n", arr[i]); for(i=0; i<n; i++) { pos = i; for(j=i+1; j<n; j++) { if(arr[j] < arr[pos]) pos = j; } if(pos != i) { temp = arr[i]; arr[i] = arr[pos]; arr[pos] = temp;
else if(y > 0) z = y; else { z = x; y = x + 1; } z = z + 1; printf("%d\n%d\n%f", x, y, z); }