C Assignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

UNIT 1/ Class 1 Test 1

C Programming & RDBMS/ A1-A

Assignment Questions A1- A A1.A.Q1. What will be output of the following c program? #include<stdio.h> static num=5; int num; extern int num; int main(){ printf("%d",num); return 0; } A1.A.Q2. What will be output of the following c program? #include<stdio.h> int main(){ int abcdefghijklmnopqrstuvwxyz123456789=10; int abcdefghijklmnopqrstuvwxyz123456=40; printf("%d",abcdefghijklmnopqrstuvwxyz123456); return 0; } A1.A.Q3. What will be output of the following c program? #include<stdio.h> int main(){ int ABC=10; printf("%d",abc); return 0; } A1.A.Q4. Which of the following statements are correct about data types? 1) If the integer literal exceeds the range of byte, a compilation error will occur. 2) We cannot implicitly convert non-literal numeric types of larger storage size to byte. 3) Byte cannot be implicitly converted to float. 4) A char can be implicitly converted to only int data type. 5) We can cast the integral character codes. A. 1, 3, 5 B. 2, 4 C. 3, 5 D. 1, 2, 5 A1.A.Q5. Which of the following statements is correct? A. Information is never lost during narrowing conversions. B. The CInteger() function can be used to convert a Single to an Integer. C. Widening conversions take place automatically. D. Assigning an Integer to an Object type is known as Unboxing. E. 3.14 can be treated as Decimal by using it in the form 3.14F.

[A1A.1]

Panimalar Engineering College

UNIT 1/ Class 1 Test 1

C Programming & RDBMS/ A1-A

A1.A.Q6. Consider on following declaration: (i) short i=10; (ii) static i=10; (iii) unsigned i=10; (iv) const i=10; (A) Only (iv) is incorrect (B) Only (ii) and (iv) are incorrect (C) Only (ii) (iii) and (iv) are correct (D) Only (iii) is correct (E) All are correct declaration A1.A.Q7. What is the range of signed int data type in that compiler in which size of int is two byte? (A)-255 to 255 (B) -32767 to 32767 (C) -32768 to 32768 (D)-32767 to 32768 (E) -32768 to 32767 A1.A.Q8. If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function.explain ? A1.A.Q9. Which of the following special symbol allowed in a variable name? a. (asterisk) b.| (pipeline) c. (hyphen) d. (underscore) A1.A.Q10.What will be output of the following c program? #include<stdio.h> int main(){ int goto=5; printf("%d",goto); return 0; } A1.A.Q11. What does static variable mean in C? A1.A.Q12. Consider on following declaration in c: (i)short const register i=10; (ii)static volatile const int i=10; (iii)unsigned auto long register i=10; (iv)signed extern float i=10.0; (A) Only (iv) is correct (B) Only (ii) and (iv) is correct (C) Only (i) and (ii) is correct (D) Only (iii) correct (E) All are correct declaration

[A1A.2]

Panimalar Engineering College

UNIT 1/ Class 1 Test 1

C Programming & RDBMS/ A1-A

A1.A.Q13. What will be the output of the following code snippet when it is executed? int x = 1; float y = 1.1f; short z = 1; printf( %f ,((float) x + y * z - (x += (short) y)); A1.A.Q14. What will be output of the following c program? #include<stdio.h> int main(){ register xyz_123=91; auto pqr_123=991; const _1a1_=pqr_123+~xyz_123; printf("%d",_1a1_); return 0; } A1.A.Q15. Which of the following is the correct size of a Decimal data type? A.8 Bytes B.4 Bytes C.10 Bytes D.16 Bytes E. None of the above. A1.A.Q16. Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified? A. float pi = 3.14F; B. #define pi 3.14F; C. const float pi = 3.14F; D. const float pi; pi = 3.14F; E. pi = 3.14F; A1.A.Q17. What will be output of the following c program? #include<stdio.h> int main(){ long int 1a=5l; printf("%ld",1a); return 0; } A1.A.Q18. What will be output of the following c program? #include<stdio.h> int main(){ int max-val=100; int min-val=10;

[A1A.3]

Panimalar Engineering College

UNIT 1/ Class 1 Test 1

C Programming & RDBMS/ A1-A

int avg-val; avg-val = max-val + min-val / 2; printf("%d",avg-val); return 0; } A1.A.Q19. By default a real number is treated as a a. Float b. double c. long double d. far double A1.A.Q20. How would you round off a value from 1.66 to 2.0? a. ceil(1.66) b. floor(1.66) c. roundup(1.66) d. roundto(1.66) A1.A.Q21. Is the following statement a declaration or definition? extern int i; A. Declaration B. Definition C. Function D. Error A1.A.Q22. Which of the following is not user defined data type? i). struct book { char name[10]; float price; int pages; }; ii). long int l = 2.35; iii). enum day {Sun, Mon, Tue, Wed}; A. 1 B. 2 C. 3 D. Both 1 and 2 A1.A.Q23. Identify which of the following are declarations i). extern int x; ii).float square (float x) {...} iii). double pow(double, double); A. 1 B. 2 C. 1 and 3 D. 3

[A1A.4]

Panimalar Engineering College

UNIT 1/ Class 1 Test 1

C Programming & RDBMS/ A1-A

A1.A.Q24. In the following program where is the variable a getting defined and where it is getting declared? #include<stdio.h> int main() { extern int a; printf("%d\n", a); return 0; } int a=20; A. extern int a is declaration, int a = 20 is the definition B. int a = 20 is declaration, extern int a is the definition C. int a = 20 is definition, a is not defined D. a is declared, a is not defined A1.A.Q25. What is the output of the program given below? #include<stdio.h> int main() { enum status { pass, fail, atkt}; enum status stud1, stud2, stud3; stud1 = pass; stud2 = atkt; stud3 = fail; printf("%d, %d, %d\n", stud1, stud2, stud3); return 0; } A1.A.Q26. What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include<stdio.h> int main() { extern int i; i = 20; printf("%d\n", sizeof(i)); return 0; } A1.A.Q27.Which of the following operations are INCORRECT? A. int i = 35; i = i%5; B. short int j = 255; j = j; C. long int k = 365L; k = k; D. float a = 3.14; a = a%3;

[A1A.5]

Panimalar Engineering College

UNIT 1/ Class 1 Test 1

C Programming & RDBMS/ A1-A

A1.A.Q28. What is the output of the program #include<stdio.h> int main() { int a[5] = {2, 3}; printf("%d, %d, %d\n", a[2], a[3], a[4]); return 0; } A1.A.Q29.List out features and application of C language ? A1.A.Q30. List out Rules of real constant ?

[A1A.6]

Panimalar Engineering College

You might also like