Questions 1-7 carry 2 marks each. Find errors if any, else give only output for the code or code segment. Assume all necessary header files are included in the program.
1. void main() { int array[]={2,3,4,5}; int *arptr=array; int value=*arptr; cout<<value<<"\t"; value=*arptr++; cout<<value<<"\t"; value=*arptr; cout<<value<<"\t"; value=*++arptr; cout<<value<<"\t"; }
7. void main() { int i = 0; for(int i = 0 ;i < 26 ; i += 2) printf("%c",i["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]); }
8. Name the header files for the following: (2) A. random B. setw C. isalpha D. gets
9. What are access specifiers? Explain with examples. (3)
10. List all the data types in C in the increasing order of sizes. (2)
11. Differentiate briefly the following with illustrative code segments. (14) A. Local and global variables B. Call by reference and Call by value C. Runtime error and Syntax error D. Structure and array E. For loop and do while loop F. Break and continue G. Logical operator and Arithmetic operator
12. Write a code segment to Swap two values a = 10 and b = 30 without using a third variable. (2)
13. Write a function in C/C++ to print the Pascals triangle. If input is 4, then the output will be 1 1 2 1 (4) 1 2 3 2 1 1 2 3 4 3 2 1
14. Write a program to find if the given number is palindrome or not. For example, the number 4321234 is a palindrome as it reads the same from left to right and from right to left. (5) (Do not use an integer array)
15. Write a program to find GCD of two numbers. (4)