Tss Mock Placement - Technical Test

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 Mp_tss_july2k17
M
Mp_tss_july2k17
Community Contributor
Quizzes Created: 2 | Total Attempts: 1,986
| Attempts: 172 | Questions: 30
Please wait...
Question 1 / 30
0 %
0/100
Score 0/100
1. What is the similarity between a structure, union and enumeration? 

Explanation

All of the options mentioned - structure, union, and enumeration - allow the user to define new data types. These data types can be used to create variables that can store different kinds of values. Structures allow the user to combine different data types into a single entity, unions allow the user to define a data type that can hold different types of values at different times, and enumerations allow the user to define a set of named values for a variable. Therefore, all three options allow the user to define new data types.

Submit
Please wait...
About This Quiz
Tss Mock Placement - Technical Test - Quiz

You will have 30 minutes to answer these 30 questions. NO NEGATIVE MARKING.
NOTE: Do not forget to mention your details.
If you have any queries, contact :
YUVRAJ SINGH (98035-53661)
KARAN SHARMA (95699-99810)

Personalize your quiz and earn a certificate with your name on it!
2. In C, if you pass an array as an argument to a function, what actually gets passed?

Explanation

When you pass an array as an argument to a function in C, only the base address of the array gets passed. This means that the function will have access to the memory location where the array starts, allowing it to access and modify the elements of the array using pointer arithmetic. By having the base address, the function can effectively work with the entire array, not just the first element or the last element.

Submit
3. How will you free the memory allocated by the following program?  #include #include #define MAXROW 3 #define MAXCOL 4 int main() { int **p, i, j; p = (int **) malloc(MAXROW * sizeof(int*)); return 0; }

Explanation

The correct answer is "free(p)". This is because the program allocates memory using the malloc() function, which dynamically allocates memory on the heap. In order to free this memory and prevent memory leaks, the free() function should be used. The argument passed to free() should be the pointer to the memory that was allocated, in this case "p". Therefore, the correct way to free the memory allocated by the program is to use the free(p) statement.

Submit
4. Let x be an array. Which of the following operations are illegal?

Explanation

The given question asks which of the operations are illegal on an array "x". The operation "x*2" is illegal because you cannot multiply an array by a scalar value. Arrays are not directly compatible with arithmetic operations like multiplication.

Submit
5. Input/output function prototypes and macros are defined in which header file? 

Explanation

The correct answer is stdio.h. This header file contains the necessary function prototypes and macros for input/output operations in C programming language. It provides functions like printf() and scanf() for formatted output and input respectively.

Submit
6. Any C program

Explanation

In the C programming language, a program must contain at least one function. A function is a block of code that performs a specific task, and it is the basic building block of a C program. Without a function, the program would not have any executable code and would not be able to perform any actions. Therefore, it is necessary for a C program to have at least one function in order to be valid and functional.

Submit
7. What do the following declaration signify?  char *arr[10];

Explanation

The declaration "char *arr[10]" signifies that arr is an array of 10 character pointers. This means that arr is a collection of 10 memory addresses, where each address points to a character value.

Submit
8. The maximum combined length of the command-line arguments including the spaces between adjacent arguments is 

Explanation

The length of command-line arguments can vary depending on the operating system. Different operating systems may have different limits on the maximum combined length of command-line arguments. Therefore, the maximum combined length of command-line arguments including the spaces between adjacent arguments may vary from one operating system to another.

Submit
9. What will the function rewind() do?

Explanation

The function rewind() is used to reposition the file pointer to the beginning of the file. It does not reposition the file pointer to a character reverse or to the end of the file. Therefore, the correct answer is "Reposition the file pointer to the beginning of that line."

Submit
10. What do the 'c' and 'v' in argv stands for? 

Explanation

The 'c' in argv stands for argument count, which represents the number of arguments passed to the program. The 'v' stands for argument vector, which refers to an array of strings that contains the actual arguments passed to the program.

Submit
11. What do the following declaration signify?  int (*pf)();

Explanation

The declaration "int (*pf)();" signifies that pf is a pointer to a function which returns an integer. This means that pf can be used to store the address of a function that returns an integer value.

Submit
12. What do the following declaration signify?  char **argv;

Explanation

The declaration "char **argv" signifies that "argv" is a pointer to a char pointer. This means that "argv" is a variable that stores the memory address of a pointer to a char variable. It is commonly used in C and C++ programs to store command-line arguments passed to a program.

Submit
13. Determine Output: void main() { static int var = 5; printf("%d ", var--); if(var) main(); }

Explanation

The program starts by initializing a static variable "var" to 5. Then it prints the value of "var" (5) and decrements it by 1. It then checks if "var" is non-zero, which it is, so it calls the main function recursively. This process continues until "var" becomes 0. Each time the main function is called recursively, it prints the value of "var" and decrements it. Therefore, the output will be 5 4 3 2 1.

Submit
14. What will be output if you will compile and execute the following c code? void main(){ char *str="Hello world"; printf("%d",printf("%s",str)); }

Explanation

The code initializes a pointer variable `str` to point to the string "Hello world". The `printf` function is used to print the string `str`, which returns the number of characters printed. This return value is then printed using `printf` again. So, the output will be "Hello world" followed by the number of characters in the string, which is 11.

Submit
15. Determine output: main() { int i = abc(10); printf("%d", --i); } int abc(int i) { return(i++); }

Explanation

The output of the code will be 9. In the main function, the variable i is assigned the value returned by the abc function, which is 10. Then, the value of i is decremented by 1 using the pre-decrement operator (--i). Since the pre-decrement operator is used, the value of i will be decremented before it is printed using the printf function. Therefore, the output will be 9.

Submit
16. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

Explanation

If a value is assigned to an array element whose subscript exceeds the size of the array, it means that the program is accessing memory outside the bounds of the array. This can lead to overwriting important data that is stored in adjacent memory locations. As a result, the program may crash or produce unexpected behavior.

Submit
17. What is stderr? 

Explanation

Stderr stands for standard error streams. In computer programming, it refers to the stream where error messages and diagnostic information are typically sent. It is a way for programs to communicate errors or exceptional conditions to the user or to other parts of the program. By separating the standard error stream from the standard output stream, developers can easily distinguish between regular program output and error messages, allowing for better error handling and debugging.

Submit
18. What is x in the following program? #include int main() { typedef char (*(*arrfptr[3])())[10]; arrfptr x; return 0; }

Explanation

The given program declares x as an array of three function pointers. The typedef statement creates a new type arrfptr, which is an array of three pointers to functions that return a pointer to an array of ten characters. The declaration arrfptr x; then creates an array named x of type arrfptr, which means x is an array of three function pointers.

Submit
19. Which standard library function will you use to find the last occurance of a character in a string in C? 

Explanation

The strrchr() function is the correct answer because it is a standard library function in C that is used to find the last occurrence of a character in a string. It takes two arguments - the string in which to search for the character, and the character to search for. The function returns a pointer to the last occurrence of the character in the string, or NULL if the character is not found.

Submit
20. Determine output:void main(){int i=10;i = !i>14;printf("i=%d", i);}

Explanation

The given code snippet assigns the value of 10 to the variable 'i'. Then, it checks if the logical NOT of 'i' (which is 10) is greater than 14. Since this condition is false, the value assigned to 'i' becomes 0. Finally, the code prints the value of 'i', which is 0.

Submit
21. What is the sequence for preprocessor to look for the file within ?

Explanation

The preprocessor first looks for the file in the predefined location, which is a specific location set by the system or compiler. If the file is not found in the predefined location, then the preprocessor searches for it in the current directory, which is the directory where the program is being compiled from. This sequence ensures that the preprocessor checks the commonly used and system-defined locations first before looking in the current directory.

Submit
22. Which among the following is right? 

Explanation

The answer is "sizeof(struct stemp*) = sizeof(union utemp*) = sizeof(char *)". This means that the size of a pointer to a struct, a pointer to a union, and a pointer to a char are all the same. The size of a pointer depends on the architecture and the compiler being used, so it is not possible to determine the exact size without more information.

Submit
23. How is search done in #include and #include "somelibrary.h" according to C standard? 

Explanation

According to the C standard, when #include is used, the search for 'somelibrary' is done in implementation-defined places. Similarly, when #include "somelibrary.h" is used, the search is also done in implementation-defined places. Therefore, the correct answer states that the search for 'somelibrary' is done in implementation-defined places for both cases.

Submit
24. What will be output if you will compile and execute the following c code? void main(){ int i=4,x; x=++i+++i+++i; printf("%d",x); }

Explanation

The code uses the pre-increment operator (++i) multiple times on the same variable (i) in the same expression. According to the operator precedence rules, the rightmost ++i is evaluated first, incrementing i to 5. Then, the next ++i is evaluated, incrementing i to 6. Finally, the leftmost ++i is evaluated, incrementing i to 7. The value of i is then added three times (7+7+7) and assigned to x, resulting in x=21. Therefore, the output of the code will be 21.

Submit
25. What will happen after compiling and running following code?main(){printf("%p", main);}

Explanation

The code will not make an infinite loop. Instead, it will print the address of the main function. The code uses the printf function to print the address of the main function, which is represented by the format specifier "%p". Therefore, the correct answer is "Some address will be printed".

Submit
26. Determine the Final Output: void main() { printf("\nab"); printf("\bsi"); printf("\rha"); }

Explanation

The given code snippet is written in C programming language.

The first line of code `printf("ab");` prints the string "ab" to the console.

The second line of code `printf("\bsi");` uses the backspace escape sequence (\b) to move the cursor back one position, effectively erasing the last character 'b' from the previous line. It then prints the string "si" to the console.

The third line of code `printf("\rha");` uses the carriage return escape sequence (\r) to move the cursor to the beginning of the line. It then prints the string "ha" to the console, overwriting the previous content.

Therefore, the final output is "hai".

Submit
27. What will be the output of the following program? #include #define square(x) x*x void main() { int i; i = 64/square(4); printf("%d", i); }

Explanation

The program defines a macro `square(x)` which calculates the square of a number. In the main function, the variable `i` is assigned the value of 64 divided by the square of 4, which is 64/16. Therefore, the value of `i` is 4. However, the program does not have a `printf` statement to print the value of `i`, so the output of the program will be nothing.

Submit
28. In the following code what is 'P'?  typedef char *charp; const charp P;

Explanation

The code declares 'P' as a constant. The 'typedef' keyword is used to create an alias 'charp' for the type 'char *' (pointer to char). The 'const' keyword is then used to make 'P' a constant, meaning its value cannot be changed once it is assigned. Therefore, the correct answer is that 'P' is a constant.

Submit
29. What is the output of this C code?#include main(){if (sizeof(int) > -1)printf("True");elseprintf("False");}

Explanation

The code compares the size of the integer data type with the value -1. Since the size of the integer is always a positive value, the condition sizeof(int) > -1 will always evaluate to true. Therefore, the code will print "True". However, the given answer is "False", which contradicts the explanation. Therefore, the correct answer cannot be determined based on the given information.

Submit
30. What will be the size of the following structure? #include struct temp { int a[10]; char p; };

Explanation

The size of the structure is determined by the sum of the sizes of its individual members. In this case, the structure has an array of integers with a size of 10 integers, which would be 10 * sizeof(int). It also has a character variable, which has a size of sizeof(char). Therefore, the total size of the structure would be the sum of these two sizes, which is 10 * sizeof(int) + sizeof(char). Calculating this would result in the answer of 44.

Submit
View My Results

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

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

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 16, 2017
    Quiz Created by
    Mp_tss_july2k17
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is the similarity between a structure, union and enumeration? 
In C, if you pass an array as an argument to a function, what actually...
How will you free the memory allocated by the following program? ...
Let x be an array. Which of the following operations are illegal?
Input/output function prototypes and macros are defined in which...
Any C program
What do the following declaration signify?  char *arr[10];
The maximum combined length of the command-line arguments including...
What will the function rewind() do?
What do the 'c' and 'v' in argv stands for? 
What do the following declaration signify?  int (*pf)();
What do the following declaration signify?  char **argv;
Determine Output:...
What will be output if you will compile and execute the following c...
Determine output:...
What will happen if in a C program you assign a value to an array...
What is stderr? 
What is x in the following program?...
Which standard library function will you use to find the last...
Determine output:void main(){int i=10;i =...
What is the sequence for preprocessor to look for the file within ?
Which among the following is right? 
How is search done in #include and #include "somelibrary.h" according...
What will be output if you will compile and execute the following c...
What will happen after compiling and running following...
Determine the Final Output:...
What will be the output of the following program?...
In the following code what is 'P'? ...
What is the output of this C code?#include main(){if (sizeof(int) >...
What will be the size of the following structure?...
Alert!

Advertisement