0
Alien head

Programming in C

Description: Test to check and improve basic skills of C programming.
Number of Questions: 15
Created by:
Tags: programming c variable function Functions Java/Oracle /C/C++ Arrays and Pointers Operators and Expression Data Types Variables and Storage Classes Structure, Unions and Enumerations
Attempted 0/15 Correct 0 Score 0

Which of the following are true about C functions?
a. C functions are used to avoid rewriting same code again and again in a program.
b. There is no limit in calling C functions.
c. We can call a function from any other function in a program.
d. A large C program can easily be tracked when it is divided into functions.
e. The core concept of C functions is reusability.
f. A function can call itself.

  1. a, c, d, e, f

  2. a, b, d, e, f

  3. a, d, e, f

  4. a, b, c, d, e

  5. All statements are true


Correct Option: E
Explanation:

All statements are true. There is no mistake in any statement.

Which of the following is a valid comparison?

  1. p=3;

  2. 3==p;

  3. p==3;

  4. both 1 and 2

  5. both 2 and 3


Correct Option: E
Explanation:

Both of option (2) and (3) are valid comparison statements.
The operator == checks if the values of two operands are equal or not, if yes then condition becomes true.

Which of the following is not stored in CPU memory?

  1. auto

  2. extern

  3. static

  4. register

  5. none of the above


Correct Option: D
Explanation:

register variables are stored in register memory.
register
is a storage specifier used to enable faster access of a variable.

Which of the following statements is/are incorrect about C array?

  1. Array is a collection of variables belongings to the same data type.

  2. Array may belong to any of the pre-defined data types.

  3. Array size may be a variable or constant value.

  4. Contiguous memory locations are used to store array elements in the memory.

  5. None of the above


Correct Option: C
Explanation:

The statement is incorrect about array.
Array size must be a constant value.

____ and ____ are the format specifiers used to print integers.

  1. %c and %d

  2. %f and %d

  3. %i and %d

  4. %c and %f

  5. %c and %i


Correct Option: C
Explanation:

%i and %d are used to print integers.
These are identical for printf( ) but different for scanf( ).

What is the range of unsigned long int?

    • 32768 to 32767
    • 2147483648 to 2147483647
  1. 0 to 255

  2. 0 to 65535

  3. 0 to 4294967295


Correct Option: E
Explanation:

Correct answer; The range of unsigned long int is 0 to 4294967295.

Which of the following is an invalid array declaration?

  1. int a[ ];

  2. int a[5];

  3. int a[ ] = {4, 2, 5, 6, 7};

  4. int a[5] = {4, 2, 5, 6, 7};

  5. none of above


Correct Option: A
Explanation:

int a[ ]; is an invalid array declaration because size of array is not specified.

Which of the following is/are incorrect about C language?
a. C language was developed at Bell Laboratories in 1980 by Dennis Ritchie.
b. C language features were derived from earlier language called B.
c. C language was invented for implementing UNIX operating system.
d. C language is a object oriented programming language.

  1. a and b

  2. b and c

  3. a and d

  4. b, c and d

  5. a, b and d


Correct Option: C
Explanation:

Both of statement (a) and (d) are incorrect about C language.
a) C language was developed at Bell Laboratories in 1972 by Dennis Ritchie.
d) C language is a structure oriented programming language.

________ are used to compare the value of two variables.

  1. Arithmetic operators

  2. Assignment operators

  3. Relational operators

  4. Logical operators

  5. Conditional operators


Correct Option: C
Explanation:

Relational operators are used to compare the value of two variables.
>, <, >=. <=, == and != are relational operators.

Which of the following is/are correct about C structures and unions?

  1. A structure allocates one common storage space for all its members.

  2. A union allocates storage space for all its members separately.

  3. A structure occupies lower memory space than union.

  4. We can access only one member of union at a time.

  5. All of the above


Correct Option: D
Explanation:

The statement is true about union.
We can access only one member of union at a time because union allocates one common storage space for all its members.

Which of the following is a low level language?

  1. C

  2. C++

  3. Java

  4. Python

  5. Assembly language


Correct Option: E
Explanation:

Assembler is a low level language.
Low level languages provides nothing other than access to the machines basic instruction set

Which of the following has error?

  1. // C is a very simple language.

  2. // C is a very simple language //.

  3. /* C is a very simple language */.

  4. /* C is a very simple language.

  5. // C is a very simple language */.


Correct Option: D
Explanation:

Incomplete comment! There shoud be a / in the last of the statement.
/
________*/ is used to create single line and multiple line comments.

Which of the following is an invalid expression?

  1. a=b+c;

  2. a=b+5;

  3. 5=a;

  4. a=5;

  5. 5==a;


Correct Option: C
Explanation:

5=a; is an invalid statement.
= is an assignment operator and left operand of the assignment operator must be a variable.

Which of the following are valid identifiers in C?
a. empsal101
b. emp.sal101
c. 101emp_sal
d. emp sal 101
e. emp_sal101
f. 101empsal
g. emp101sal

  1. a, c, g

  2. b, d, f

  3. a, e, g

  4. b, c, d

  5. e, f, g


Correct Option: C
Explanation:

All of (a) empsal101, (e) emp_sal101 and (g) emp101sal are valid identifiers.
(b) emp.sal101, (c) 101emp_sal, (d) emp sal 101 and (f) 101empsal have mistakes.
In (b) emp.sal101 fullstop is used. (No other special symbol rather than underscore can't be used in names of identifiers.)
In (c) 101emp_sal a number is used in starting of identifier. (An identifier should not start with a number.)
In (d) emp sal 101 spaces are used. (Spaces are not allowed within names of identifiers.)
In (f) 101empsal a number is used in starting of identifier. (An identifier should not start with a number.)

In a structure oriented language a program is divided into small programs called ________.

  1. objects

  2. classes

  3. Union

  4. functions

  5. operators


Correct Option: D
Explanation:

In a structure oriented language a program is divided into small programs called functions.
C functions are basic building blocks in a program. All C programs are written using functions to improve reusability, understandability and to keep track on them. A large C program is divided into basic building blocks called C function. C function contains set of instructions enclosed by “{}” which performs specific operation in a C program. Actually, Collection of these functions creates a C program.

+ View questions