C-Questions 1. C99 Standard Guarantees Uniqueness Of

C-Questions 1. C99 Standard Guarantees Uniqueness Of

C-questions 1. C99 standard guarantees uniqueness of __________ characters for internal names. a) 31 b) 63 c) 12 d) 14 2. C99 standard guarantees uniqueness of ___________ characters for external names. a) 31 b) 6 c) 12 d) 14 3. Which of the following is not a valid variable name declaration? a) int __a3; b) int __3a; c) int __A3; d) None of the mentioned 4. Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________ a) Compiler and linker implementations b) Assemblers and loaders implementations c) C language d) None of the mentioned 5. What will be the output of the following C code? #include <stdio.h> int main() { int a[5] = {1, 2, 3, 4, 5}; int i; for (i = 0; i < 5; i++) if ((char)a[i] == '5') printf("%d\n", a[i]); else printf("FAIL\n"); } a) The compiler will flag an error b) The program will compile and print the output 5 c) The program will compile and print the ASCII value of 5 d) The program will compile and print FAIL for 5 times 6. The format identifier ‘%i’ is also used for _____ data type. a) char b) int c) float d) double 7. What will be the output of the following C code? #include <stdio.h> int main() { signed char chr; chr = 128; printf("%d\n", chr); return 0; } a) 128 b) -128 c) Depends on the compiler d) None of the mentioned 8. enum types are processed by _________ a) Compiler b) Preprocessor c) Linker d) Assembler 9. What will be the output of the following C code? #include <stdio.h> int main() { const int p; p = 4; printf("p is %d", p); return 0; } a) p is 4 b) Compile time error c) Run time error d) p is followed by a garbage value 10 Which of the following statement is false? a) Constant variables need not be defined as they are declared and can be defined later b) Global constant variables are initialized to zero c) const keyword is used to define constant values d) You cannot reassign a value to a constant variable 11.What will be the output of the following C code? #include <stdio.h> int main() { const int i = 10; int *ptr = &i; *ptr = 20; printf("%d\n", i); return 0; } a) Compile time error b) Compile time warning and printf displays 20 c) Undefined behaviour d) 10 12. Which of the following declaration is not supported by C? a) String str; b) char *str; c) float str = 3e2; d) Both String str; & float str = 3e2; 13. What will be the output of the following C code? #include <stdio.h> int main() { int i = 3; int l = i / -2; int k = i % -2; printf("%d %d\n", l, k); return 0; } a) Compile time error b) -1 1 c) 1 -1 d) Implementation defined 14. What will be the final value of x in the following C code? #include <stdio.h> void main() { int x = 5 * 9 / 3 + 9; } a) 3.75 b) Depends on compiler c) 24 d) 3 15. In which stage the following code #include<stdio.h> gets replaced by the contents of the file stdio.h A. During editing B. During linking C. During execution D. During preprocessing 16. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would report an error. C. The program may crash if some important data gets overwritten. D. The array size would appropriately grow. 17. What does the following declaration mean? int (*ptr)[10]; A. ptr is array of pointers to 10 integers B. ptr is a pointer to an array of 10 integers C. ptr is an array of 10 integers D. ptr is an pointer to array 18. In C, if you pass an array as an argument to a function, what actually gets passed? A. Value of elements in array B. First element of the array C. Base address of the array D. Address of the last element of array 19. How will you free the allocated memory ? A. remove(var-name); B. free(var-name); C. delete(var-name); D. dalloc(var-name); 20. What is the similarity between a structure, union and enumeration? A. All of them let you define new values B. All of them let you define new data types C. All of them let you define new pointers D. All of them let you define new structures 21. What will be the output of the program ? #include<stdio.h> int main() { union a { int i; char ch[2]; }; union a u; u.ch[0]=3; u.ch[1]=2; printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i); return 0; } A. 3, 2, 515 B. 515, 2, 3 C. 3, 2, 5 D. 515, 515, 4 22. What will be the output of the program ? #include<stdio.h> int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit={1, 2, 13}; printf("%d, %d, %d\n", bit.bit1, bit.bit3, bit.bit4); return 0; } A. 1, 2, 13 B. 1, 4, 4 C. -1, 2, -3 D. -1, -2, -13 23. Point out the error in the program? struct emp { int ecode; struct emp *e; }; A. Error: in structure declaration B. Linker Error C. No Error D. None of above 24. Point out the error in the program? typedef struct data mystruct; struct data { int x; mystruct *b; }; A. Error: in structure declaration B. Linker Error C. No Error D. None of above 25. Which of the following statements correct about the below program? #include<stdio.h> int main() { struct emp { char name[25]; int age; float sal; }; struct emp e[2]; int i=0; for(i=0; i<2; i++) scanf("%s %d %f", e[i].name, &e[i].age, &e[i].sal); for(i=0; i<2; i++) scanf("%s %d %f", e[i].name, e[i].age, e[i].sal); return 0; } A. Error: scanf() function cannot be used for structures elements. B. The code runs successfully. C. Error: Floating point formats not linked Abnormal program termination. D. Error: structure variable must be initialized. 26. If the two strings are identical, then strcmp() function returns A. -1 B. 1 C. 0 D. Yes 27. The library function used to find the last occurrence of a character in a string is A. strnstr() B. laststr() C. strrchr() D. strstr() 28. What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; } A. Hello B. World C. Hello World D. WorldHello 29. What will be the output of the program ? #include<stdio.h> int main() { char p[] = "%d\n"; p[1] = 'c'; printf(p, 65); return 0; } A. A B. a C. c D. 65 30. What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { printf("%d\n", strlen("123456")); return 0; } A. 6 B. 12 C. 7 D. 2 31. Which of the following statements are correct about the below declarations? char *p = "Sanjay"; char a[] = "Sanjay"; 1: There is no difference in the declarations and both serve the same purpose. 2: p is a non-const pointer pointing to a non-const string, whereas a is a const pointer pointing to a non-const pointer. 3: The pointer p can be modified to point to another string, whereas the individual characters within array a can be changed. 4: In both cases the '\0' will be added at the end of the string "Sanjay". A. 1, 2 B. 2, 3, 4 C. 3, 4 D. 2, 3 32. Will the program compile successfully? #include<stdio.h> int main() { char a[] = "India"; char *p = "BIX"; a = "BIX"; p = "India"; printf("%s %s\n", a, p); return 0; } A. Yes B. No 33. The keyword used to transfer control from a function back to the calling function is A. switch B. goto C. go back D. return 34. What will be the output of the program? #include<stdio.h> void fun(int*, int*); int main() { int i=5, j=2; fun(&i, &j); printf("%d, %d", i, j); return 0; } void fun(int *i, int *j) { *i = *i**i; *j = *j**j; } A. 5, 2 B. 10, 4 C. 2, 5 D. 25, 4 35. Which of the following statements are correct about the program? #include<stdio.h> int main() { printf("%p\n", main()); return 0; } A. It prints garbage values infinitely B. Runs infinitely without printing anything C. Error: main() cannot be called inside printf() D. No Error and print nothing 36. Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; } A. The function calculates the value of 1 raised to power num. B. The function calculates the square root of an integer C. The function calculates the factorial value of an integer D. None of above 37. Which of the following statements are correct about the program? #include<stdio.h> int main() { printf("%p\n", main()); return 0; } A. It prints garbage values infinitely B. Runs infinitely without printing anything C. Error: main() cannot be called inside printf() D. No Error and print nothing 38. Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; } A.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    66 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us