Medha -the Programming Quiz

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 Medha1
M
Medha1
Community Contributor
Quizzes Created: 1 | Total Attempts: 718
| Attempts: 718 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. Specify the 2 library functions to dynamically allocate memory?

Explanation

The correct answer is malloc() and calloc(). These are two library functions used to dynamically allocate memory in C programming. malloc() is used to allocate a block of memory of a specified size, while calloc() is used to allocate and initialize a block of memory for an array of elements. Both functions are commonly used in C programming for dynamic memory allocation.

Submit
Please wait...
About This Quiz
Medha -the Programming Quiz - Quiz

MEDHA - The programming quiz tests your understanding of C programming. It includes questions on code outputs, memory management, and operator precedence, assessing key C programming skills.

2. The correct order of mathematical operators in mathematics and computer programming,

Explanation

In mathematics and computer programming, the correct order of mathematical operators is known as the order of operations. This order dictates that division should be done before multiplication, and multiplication should be done before addition and subtraction. This is because division and multiplication have higher precedence than addition and subtraction. Therefore, the correct order of mathematical operators is Division, Multiplication, Addition, Subtraction.

Submit
3.  What is the output of the below code snippet?#include<stdio.h> main(){   for(;;)printf("Hello");}

Explanation

The code snippet contains an infinite loop because there are no conditions specified in the for loop. The loop will continue to execute indefinitely, repeatedly printing "Hello" without any interruption or termination.

Submit
4. Which of the following statement shows the correct implementation of nested conditional operation by finding greatest number out of three numbers?

Explanation

The correct implementation of nested conditional operation to find the greatest number out of three numbers is shown in the answer "max = a>b ? a>c?a:c:b>c?b:c". This statement uses nested ternary operators to compare the numbers and determine the maximum value. The first ternary operator compares a and b, and if a is greater, it compares a with c to determine the maximum. If b is greater, it compares b with c to determine the maximum. This way, the statement finds the greatest number among a, b, and c.

Submit
5. A Variable name in C includes which special symbols?

Explanation

In C, a variable name can include the underscore symbol (_). This symbol is often used to separate words within a variable name to improve readability. For example, a variable name like "first_name" is more descriptive than "firstname". The other special symbols listed, such as asterisk, hash, and addition, are not allowed in variable names in C.

Submit
6. In C, what are the various types of real data type (floating point data type)?

Explanation

The correct answer is float, double, long double. In the C programming language, the various types of real data types or floating point data types are float, which is used to store single-precision floating point numbers, double, which is used to store double-precision floating point numbers, and long double, which is used to store extended-precision floating point numbers. These data types are used to represent numbers with fractional parts or numbers that are too large or too small to be represented using integer data types.

Submit
7. In C, if you pass an array as an argument to a function, what actually gets passed?

Explanation

When an array is passed as an argument to a function in C, only the base address of the array is actually passed. This means that the memory address of the first element of the array is passed to the function. By using this base address, the function can access and manipulate the elements of the array.

Submit
8. Identify the incorrect file opening mode from the following.

Explanation

The incorrect file opening mode is "x". The file opening modes "r", "w", and "a" are valid modes in Python. "r" is used for reading a file, "w" is used for writing to a file (and overwriting the existing content), and "a" is used for appending content to a file. However, "x" is not a valid file opening mode in Python.

Submit
9. Which of the following function is used to find the first occurrence of a given string in another string?

Explanation

The strstr() function is used to find the first occurrence of a given string within another string. It searches for the first instance of the specified substring and returns a pointer to the location within the original string where the substring is found.

Submit
10. To print a double value which format specifier can be used?

Explanation

The correct answer is "%If". This format specifier is used to print a double value in C programming language. The "%" symbol is used to indicate a format specifier, and "f" is used to specify that the value is a double. Therefore, "%If" is the correct format specifier to print a double value.

Submit
11. What is the output of the following program?#include<stdio.h>main(){ fprintf(stdout,"Hello, World!");}

Explanation

The program uses the fprintf function to print the string "Hello, World!" to the standard output stream (stdout). Therefore, the output of the program will be "Hello, world!".

Submit
12.  What is the output of the below code snippet?#include<stdio.h> main(){   int a = 5, b = 3, c = 4;     printf("a = %d, b = %d\n", a, b, c);}

Explanation

The code snippet will output "a = 5, b = 3". This is because the printf statement is printing the values of variables 'a' and 'b' using the format specifier "%d". The values of 'a' and 'b' are 5 and 3 respectively. The variable 'c' is not being printed in the printf statement, so its value does not affect the output.

Submit
13. C is the successor of ___ programming language.

Explanation

C++ is the successor of the C programming language. C++ was developed as an extension of the C language, adding object-oriented programming features and other enhancements. B++ and MINI C are not programming languages, and B is not the successor of the C language.

Submit
14. Choose the correct order of evaluation,

Explanation

The correct order of evaluation is Arithmetic Relational Logical Assignment. This means that arithmetic operations are performed first, followed by relational operations, then logical operations, and finally assignment operations. This order ensures that calculations are performed correctly and logical conditions are evaluated in the appropriate sequence.

Submit
15. What is the output of the following program?#include<stdio.h>void main(){   char s[ ] = "C++";    printf("%s ",s);   s++;   printf("%s",s);}

Explanation

The program will give a compile error because the line "s++;" is trying to increment the array name 's', which is not allowed in C++. Array names are constant pointers and cannot be modified.

Submit
16. What is the built in library function to adjust the allocated dynamic memory size.

Explanation

The correct answer is "realloc". The realloc function is a built-in library function in C that is used to adjust the size of dynamically allocated memory. It allows for the reallocation of memory blocks, either expanding or reducing their size. This function is particularly useful when the size of the memory needed by a program changes during its execution. By using realloc, the program can efficiently manage memory allocation and deallocation, optimizing the use of resources.

Submit
17. What is the output of the following program?#include<stdio.h> main(){   struct { int x;} var = {5}, *p = &var;     printf("%d %d %d",var.x,p->x,(*p).x);}

Explanation

The program defines a structure variable named "var" with an integer member "x" and initializes it to 5. It also declares a pointer variable "p" of the same structure type and assigns the address of "var" to it.

The printf statement prints the value of "var.x", "p->x", and "(*p).x". Since "var.x" is 5, "p->x" and "(*p).x" both access the value of "x" through the pointer "p", which points to "var". Therefore, all three values are 5.

Submit
18. Compiler generates ___ file.

Explanation

A compiler generates object code files. Object code is the output of the compilation process, where the source code is translated into a lower-level representation that can be directly executed by the computer's hardware or combined with other object code files to create an executable program. Object code is specific to the target architecture and can be further processed by a linker to generate the final executable code. Assembly code is a human-readable representation of the machine code and is generated by an assembler, not a compiler. Therefore, the correct answer is object code.

Submit
19. What is the output of the following program?#include<stdio.h>void f(){ static int i = 3;    printf("%d ", i);   if(--i) f();}main(){ f();}

Explanation

The program defines a function f() that has a static variable i initialized to 3. The function prints the value of i and then recursively calls itself with i decremented by 1. This process continues until i becomes 0. So, the output of the program will be 3 2 1.

Submit
20. Which library function can convert an integer/long to a string?

Explanation

The ltoa() function is used to convert a long integer to a string. This function takes the long integer as input and converts it into a string representation. Therefore, ltoa() is the correct library function to convert an integer/long to a string.

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
  • Feb 27, 2017
    Quiz Created by
    Medha1
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Specify the 2 library functions to dynamically allocate memory?
The correct order of mathematical operators in mathematics and...
 What is the output of the below code...
Which of the following statement shows the correct implementation of...
A Variable name in C includes which special symbols?
In C, what are the various types of real data type (floating point...
In C, if you pass an array as an argument to a function, what actually...
Identify the incorrect file opening mode from the following.
Which of the following function is used to find the first occurrence...
To print a double value which format specifier can be used?
What is the output of the following...
 What is the output of the below code...
C is the successor of ___ programming language.
Choose the correct order of evaluation,
What is the output of the following...
What is the built in library function to adjust the allocated dynamic...
What is the output of the following...
Compiler generates ___ file.
What is the output of the following...
Which library function can convert an integer/long to...
Alert!

Advertisement