[go: up one dir, main page]

0% found this document useful (0 votes)
26 views14 pages

QUIZ

The document contains a series of multiple-choice questions related to the C programming language, its syntax, data types, and basic concepts. It also includes historical information about computers and the evolution of programming languages. Additionally, there are questions about specific C code snippets and their expected outputs.

Uploaded by

chaithanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views14 pages

QUIZ

The document contains a series of multiple-choice questions related to the C programming language, its syntax, data types, and basic concepts. It also includes historical information about computers and the evolution of programming languages. Additionally, there are questions about specific C code snippets and their expected outputs.

Uploaded by

chaithanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

1. Who is the father of C language?

a) Steve Jobs
b) James Gosling
c) Dennis Ritchie
d) Rasmus Lerdorf

2. Which of the following is not a valid C variable name?


a) int number;
b) float rate;
c) int variable_count;
d) int $main;

3. 3. All keywords in C are in ____________


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None of the mentioned

4. 4. Which of the following is true for variable names in C?


a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto,
static)
c) Variable names cannot start with a digit
d) Variable can be of any length

5. 5. Which is valid C expression?


a) int my_num = 100,000;
b) int my_num = 100000;
c) int my num = 1000;
d) int $my_num = 10000;

6. 6. Which of the following cannot be a variable name in C?


a) volatile
b) true
c) friend
d) export

7. What is short int in C programming?


a) The basic data type of C
b) Qualifier
c) Short is the qualifier and int is the basic data type
d) All of the mentioned

8. Which of the following declaration is not supported by C language?


a) String str;
b) char *str;
c) float str = 3e2;
d) Both “String str;” and “float str = 3e2;”

9. Which keyword is used to prevent any changes in the variable within a C


program?
a) immutable
b) mutable
c) const
d) volatile

10. What is the result of logical or relational expression in C?


a) True or False
b) 0 or 1
c) 0 if an expression is false and any positive number if an expression is true
d) None of the mentioned

11. What is #include <stdio.h>?


a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
12. Which of the following are C preprocessors?
a) #ifdef
b) #define
c) #endif
d) all of the mentioned
13. The C-preprocessors are specified with _________ symbol.
a) #
b) $
c) ” ”
d) &
14. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
15. Which of the following is not an operator in C?
a) ,
b) sizeof()
c) ~
d) None of the mentioned
16. scanf() is a predefined function in______header file.
a) stdlib. h
b) ctype. h
c) stdio. h
d) stdarg. H
17. What is the meaning of the following C statement?
printf(“%10s”, state);
a) 10 spaces before the string state is printed
b) Print empty spaces if the string state is less than 10 characters
c) Print the last 10 characters of the string
d) None of the mentioned
18. 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
19. Which of the following is not a valid variable name declaration?
a) int _a3;
b) int a_3;
c) int 3_a;
d) int _3a
20. Which of the following is not a valid C variable name?
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
21. For which of the following, “PI++;” code will fail?
a) #define PI 3.14
b) char *PI = “A”;
c) float PI = 3.14;
d) none of the Mentioned
22. Pick out the correct statement.
a) Increment operator ++ adds 1 to its operand
b) Increment operator ++ adds 2 to its operand
c) Decrement operator ++ subtracts 1 to its operand
d) Decrement operator ++ subtracts 3 to its operand
23. The format identifier ‘%i’ is also used for _____ data type.
a) char
b) int
c) float
d) double
24. Which is correct with respect to the size of the data types?
a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > int
25. Which among the following is NOT a logical or relational operator?
a) !=
b) ==
c) ||
d) =

1.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. i = i / 3;
6. printf("%d\n", i);
7. return 0;
8. }

a) Implementation defined
b) 1
c) 3
d) Compile time error

2.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. i = i / 3;
6. printf("%d\n", i);
7. return 0;
8. }
a) Implementation defined
b) 1
c) 3
d) Compile time error

3.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = -3;
5. int k = i % 2;
6. printf("%d\n", k);
7. }
a) Compile time error
b) -1
c) 1
d) Implementation defined
4.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. int j = i++ + i;
6. printf("%d\n", j);
7. }
a) 0
b) 1
c) 2
d) Compile time error

5.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int i = 2;
5. int j = ++i + i;
6. printf("%d\n", j);
7. }
a) 6
b) 5
c) 4
d) Compile time error

6.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int a = 1, b = 1, c;
5. c = a++ + b;
6. printf("%d, %d", a, b);
7. }
a) a = 1, b = 1
b) a = 2, b = 1
c) a = 1, b = 2
d) a = 2, b = 2

7.What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. int y = 10000;
5. int y = 34;
6. printf("Hello World! %d\n", y);
7. return 0;
8. }

a) Compile time error


b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value

8.What will happen if the following C code is executed?

1. #include <stdio.h>
2. int main()
3. {
4. int main = 3;
5. printf("%d", main);
6. return 0;
7. }
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping

9.What will be the final value of x in the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }
10.What will be the output of the following C code snippet?

1. #include <stdio.h>
2. void main()
3. {
4. 1 < 2 ? return 1: return 2;
5. }
11. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 1, z = 3;
5. int y = x << 3;
6. printf(" %d\n", y);
7. }
a) -2147483648
b) -1
c) Run time error
d) 8
12. What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 0, y = 2, z = 3;
5. int a = x & y | z;
6. printf("%d", a);
7. }
a) 3
b) 0
c) 2
d) Run time error

13.What is the output

1.#include <stdio.h>
2. int main()
3. {
4. printf("sanfoundry\rclass\n");
5. return 0;
6. }

a) sanfoundryclass
b) sanfoundry
class
c) classundry
d) sanfoundry

14. What will be the output of the following C code?

1. #include <stdio.h>
2. int main()
3. {
4. const int p;
5. p = 4;
6. printf("p is %d", p);
7. return 0;
8. }
a) p is 4
b) Compile time error
c) Run time error
d) p is followed by a garbage value

 CHARLES BABBAGE INVENTED COMPUTER


 FATHER OF COMPUTER
 FIRST COMPUTER WAS CREATED IN 1822 BUT NOT CONSTRUCTED UNTIL 1991
 On 21st January 1969, the first electronic digital computer built in
India was commissioned at Bhabha Atomic Research Centre
(BARC) by Vikram Sarabhai.
 COMPUTER Full Form: Full Form of Computer is “Common
Operating Machine Purposely Used for Technological and
Educational Research”
 Classification of Computers by Size
 Supercomputers.
 Mainframe computers.
 Minicomputers.
 Personal computers (PCs) or microcomputers.
 1957: FORTRAN
 1958: ALGOL
 1959: COBOL
 1964: BASIC
 B
 1972: C

 C is the mother of almost all higher-level programming


languages like C#, D, Go, Java, JavaScript, Limbo, LPC,
Perl, PHP, Python, and Unix’s C shell.

1. Which of the following options is true with respect to computers?
a. A computer is a programmable electronic machine or device designed to take data,
process it, and provide meaningful information.
b. A computer can only understand binary language written as O's and 1's.
c. A computer is an electronic machine or device that helps to process arithmetic and
logical operations.
d. All of the above
2.

3.

4.
5.
6.

You might also like