Programming Basics Of C Language - Quiz 1 ( 6-7 June 2018 )

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Nchaudhuri31
N
Nchaudhuri31
Community Contributor
Quizzes Created: 19 | Total Attempts: 9,947
| Attempts: 319 | Questions: 30
Please wait...
Question 1 / 30
0 %
0/100
Score 0/100
1. The function that calls itself is referred to as:

Explanation

A function that calls itself is referred to as recursive. This means that the function is able to repeatedly call itself within its own code, allowing for repeated execution of a specific set of instructions. This recursive behavior is often used to solve problems that can be divided into smaller subproblems, as the function can call itself with smaller inputs until a base case is reached. This allows for a more elegant and concise solution to certain types of problems.

Submit
Please wait...
About This Quiz
C Quizzes & Trivia

Dear Student,
The Quiz consists of General MCQ on C Programming Language.
Total 30 Questions
Time Allocated : 20 Minutes
.
Happy Learning !
Team SHIVAM

2. Which is valid string function?

Explanation

strlen is a valid string function. It is used to determine the length of a string, i.e., the number of characters in the string. It returns an integer value representing the length of the string.

Submit
3. Which is valid C expression?

Explanation

The correct answer is "int my_num = 100000;". This is a valid C expression because it follows the syntax rules for declaring and initializing a variable in C. The variable "my_num" is declared as an integer and assigned the value 100000.

Submit
4. C programs are converted into machine language with the help of

Explanation

C programs are converted into machine language with the help of a compiler. A compiler is a software tool that translates the high-level source code written in a programming language like C into machine code that can be understood and executed by the computer's processor. It performs various tasks such as lexical analysis, syntax analysis, semantic analysis, and code generation to convert the source code into machine language instructions.

Submit
5. The following escape sequence represents a carriage return:

Explanation

The escape sequence "\r" represents a carriage return. When this sequence is encountered in a string, it causes the cursor to move to the beginning of the current line, effectively returning the cursor to the start of the line. This is commonly used in programming to overwrite or update text on the same line, or to create a new line of text without moving to the next line.

Submit
6. ‘enum’ is a

Explanation

The correct answer is "user defined datatype" because the keyword "enum" is used to define a set of named constants. It allows us to create a custom data type with a fixed set of values, which can be used in variables and functions. This means that "enum" is not a basic or derived datatype, nor a modifier, but rather a way to define our own data type.

Submit
7. What is the output of this program? void main() { int i=100; while(i

Explanation

The program does not have any output because there is no code inside the main function that prints anything to the console. The variable i is initialized to 100, but there is no code to manipulate or print its value. Therefore, the program does not produce any output.

Submit
8. Number of bytes required for double is

Explanation

The number of bytes required for a double data type is 8. In most programming languages, a double is a floating-point data type that is used to represent decimal numbers with a higher precision compared to a float data type. The 8 bytes of memory allocated for a double allows it to store a wider range of values with greater precision.

Submit
9. Which of the following is not a valid variable name declaration?

Explanation

The variable name "3_a" is not a valid variable name declaration because it starts with a number. In programming, variable names cannot start with a number, they must start with a letter or an underscore.

Submit
10. Variable name resolving (number of significant characters for uniqueness of variable) depends on

Explanation

The correct answer is Compiler and linker implementations. Variable name resolving, specifically the number of significant characters required for uniqueness of a variable, is determined by the way the compiler and linker are implemented. These tools are responsible for translating and linking the code, and they have their own rules and limitations for variable naming. Assemblers and loaders are not directly involved in the process of variable name resolving, so they do not affect the number of significant characters needed for uniqueness.

Submit
11. The token ‘sizeof’ is

Explanation

The token 'sizeof' is an operator in C and C++ programming languages. It is used to determine the size in bytes of a data type or a variable. It returns the size as an unsigned integer value. This operator is often used in memory allocation and manipulation operations to ensure the correct amount of memory is allocated or accessed.

Submit
12. What will happen if the below program is executed? #include int main() { int main = 3; printf("%d", main); return 0; }

Explanation

The program will print 3. This is because the variable "main" is redefined as an integer with the value of 3. When the printf statement is executed, it will print the value of the variable "main", which is 3.

Submit
13. The maximum size of the member is the size of which of the following token

Explanation

The maximum size of the member is determined by the size of the structure. In a structure, each member has its own memory space allocated, and the size of the structure is determined by the sum of the sizes of its members. Therefore, the maximum size of the member is limited by the size of the structure itself.

Submit
14. By default a function returns a value of type

Explanation

By default, a function returns a value of type int. This means that if a function does not have a return type specified, it will assume the return type to be int. The int data type is used to represent integer values, such as whole numbers.

Submit
15. In Pre-processor is taken into consideration by the compiler during

Explanation

The pre-processor is a part of the compiler that processes directives before the actual compilation process begins. It handles tasks such as including header files, macro expansion, and conditional compilation. Therefore, the pre-processor is taken into consideration by the compiler during pre-compilation.

Submit
16. In procedure oriented programming , the emphasis is on:

Explanation

In procedure-oriented programming, the emphasis is on functions. This means that the program is divided into a set of procedures or functions that perform specific tasks. Each function is responsible for a specific operation and can be called from other parts of the program. The focus is on breaking down the program into smaller, manageable units of code, making it easier to understand and maintain. Functions allow for code reuse and modular programming, promoting efficiency and organization in the program.

Submit
17. The return-type of “printf” is:

Explanation

The return-type of "printf" is "int" because "printf" is a function in the C programming language that is used to print formatted output. It returns the number of characters successfully written to the output or a negative value if an error occurs. Therefore, the return-type is "int" to indicate the number of characters printed.

Submit
18. Comment on the output of this C code? #include 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"); return 0; }

Explanation

The given code will print "FAIL" for 5 times. This is because the code is comparing the ASCII value of the elements in the array with the ASCII value of '5'. Since the ASCII value of '5' is 53, which is not equal to any of the elements in the array (1, 2, 3, 4, 5), the code will enter the else statement and print "FAIL" for each iteration of the loop.

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

Explanation

In C, "volatile" is a keyword that is used to indicate that a variable's value can be changed by external factors, such as hardware or other threads. Therefore, "volatile" cannot be used as a variable name because it is a reserved keyword in the language.

Submit
20. What is the output of this program? void main() { int a=b=c=10; a=b=c=50; printf(“\n %d %d %d”,a,b,c); }

Explanation

The program will result in a compile-time error. This is because the variables a, b, and c are not declared before being assigned values. In C, variables must be declared before they can be used. Therefore, the program will not compile successfully.

Submit
21. Which is not keyword in ‘C’ ?

Explanation

The keyword "complex" is not a keyword in the C programming language. The other options, typedef, const, and near, are all keywords in C.

Submit
22. The conversion character corresponding to long integer is

Explanation

The conversion character "%u" is used to represent an unsigned long integer in C programming. It is used to print the value of an unsigned long integer variable. The "%u" conversion character is specifically used for unsigned integers, while "%d" and "%ld" are used for signed integers. Therefore, the correct answer is "%u" for representing a long integer.

Submit
23. What is the output of the following C code(on a 64 bit machine)? #include union Sti { int nu; char m; }; int main() { union Sti s; printf("%d", sizeof(s)); return 0; }

Explanation

The output of the given code is 4.

The code defines a union named "Sti" which has two members: an integer "nu" and a character "m". The size of a union is determined by the size of its largest member. In this case, the size of the integer "nu" is 4 bytes on a 64-bit machine, so the size of the union is also 4 bytes.

The printf statement then prints the size of the union, which is 4.

Submit
24. What is the output of this C code? #include int main() { float x = 'a'; printf("%f", x); return 0; }

Explanation

The code initializes a float variable x with the ASCII value of the character 'a', which is 97. The printf statement then prints the value of x as a float, resulting in the output 97.000000.

Submit
25. What is the output of this program? void main() { int i,j; for(i=0,j=5; i

Explanation

The given program is an infinite loop because the condition in the for loop (i

Submit
26. Linking during compilation means to connect:

Explanation

Linking during compilation means to connect library function code. When a program is compiled, it may call functions that are defined in external libraries. The linking process is responsible for connecting the function calls in the program to the actual code in the library. This allows the program to access and execute the library functions when needed. Therefore, the correct answer is library function code.

Submit
27. Comment on the output of this C code? #include int main() { float f1 = 0.1; if (f1 == 0.1) printf("equal\n"); else printf("not equal\n"); return 0; }

Explanation

The output of this code is "not equal". This is because floating-point numbers cannot be represented exactly in binary, leading to small rounding errors. In this case, the value 0.1 cannot be represented exactly in binary, so when it is assigned to the variable f1, it is rounded to the nearest representable value. When comparing f1 to the value 0.1, the two values are not exactly equal due to this rounding error, so the code prints "not equal".

Submit
28. What will be output if you will compile and execute the following c code? #include "stdio.h" #include "string.h" void main() { int i=0; for(;i

Explanation

The code snippet provided includes a for loop that iterates from 0 to a certain condition. In this case, the condition is "i 0", which is not a valid condition and will result in a compilation error. Therefore, the correct answer is "Compilation error".

Submit
29. What is the output of this C code (on a 32-bit compiler)? #include int main() { int x = 10000; double y = 56; int *p = &x; double *q = &y; printf("p and q are %d and %d", sizeof(p), sizeof(q)); return 0; }

Explanation

The output of this C code is "p and q are 4 and 4". The sizeof(p) and sizeof(q) statements return the size in bytes of the variables p and q respectively. In a 32-bit compiler, the size of an integer pointer (p) and a double pointer (q) is 4 bytes each. Therefore, when the printf statement is executed, it prints "p and q are 4 and 4".

Submit
30. What is the output of this program? void main() { int i=5; while(i!=65) i++; while(i

Explanation

The program starts with initializing the variable i to 5. It then enters a while loop that increments the value of i by 1 until i becomes 65. After that, it enters another while loop that checks if i is less than 97. Since 65 is not less than 97, the loop is not executed. Therefore, the output of the program is b.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jun 03, 2018
    Quiz Created by
    Nchaudhuri31
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
The function that calls itself is referred to as:
Which is valid string function?
Which is valid C expression?
C programs are converted into machine language with the help of
The following escape sequence represents a carriage return:
‘enum’ is a
What is the output of this program? void main() { int i=100; while(i
Number of bytes required for double is
Which of the following is not a valid variable name declaration?
Variable name resolving (number of significant characters for...
The token ‘sizeof’ is
What will happen if the below program is executed? ...
The maximum size of the member is the size of which of the following...
By default a function returns a value of type
In Pre-processor is taken into consideration by the compiler during
In procedure oriented programming , the emphasis is on:
The return-type of “printf” is:
Comment on the output of this C code?...
Which of the following cannot be a variable name in C?
What is the output of this program? ...
Which is not keyword in ‘C’ ?
The conversion character corresponding to long integer is
What is the output of the following C code(on a 64 bit machine)? ...
What is the output of this C code? ...
What is the output of this program?...
Linking during compilation means to connect:
Comment on the output of this C code?...
What will be output if you will compile and execute the following c...
What is the output of this C code (on a 32-bit compiler)?...
What is the output of this program? ...
Alert!

Advertisement