Code Buzz (Language : C)

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Aniketmondal348
A
Aniketmondal348
Community Contributor
Quizzes Created: 1 | Total Attempts: 61
Questions: 30 | Attempts: 61

SettingsSettingsSettings
Code Buzz (Language : C) - Quiz

"A good programmer is someone who always looks both ways before crossing a one-way street"
Do you have a wide vision on programming?
Do you have control on several languages?
Let's check !Techtix, KGEC in association with Coding Ninjas presents Code Buzz, the competition to test your technical knowledge in Java, C & Python. Code Buzz this year has got total prizes worth Rs. 4,500. Take this challenge and register for Code Buzz this year


Questions and Answers
  • 1. 

    What do the following declaration signify? char **argv;

    • A.

      Argv is a pointer to pointer.

    • B.

      Argv is a pointer to a char pointer.

    • C.

      Argv is a function pointer.

    • D.

      Argv is a member of function pointer.

    Correct Answer
    B. Argv is a pointer to a char pointer.
    Explanation
    The declaration "char **argv" signifies that argv is a pointer to a char pointer. This means that argv is a variable that holds the memory address of a char pointer. It can be used to access or manipulate a sequence of char pointers, such as an array of strings.

    Rate this question:

  • 2. 

    Declare the following statement? "A pointer to an array of three chars".

    • A.

      Char *ptr[3]();

    • B.

      Char (*ptr)*[3];

    • C.

      Char (*ptr[3])(); 

    • D.

      Char (*ptr)[3];

    Correct Answer
    D. Char (*ptr)[3];
    Explanation
    The correct answer is "char (*ptr)[3]". This is because the declaration "char (*ptr)[3]" declares a pointer named "ptr" that points to an array of three characters. The parentheses are used to indicate that ptr is a pointer, and the brackets [3] indicate that the pointer is pointing to an array of three characters.

    Rate this question:

  • 3. 

    Which of the following statements are FALSE about the below code? int main(int ac, char *av[]) { }

    • A.

      Ac contains count of arguments supplied at command-line

    • B.

      Av[] contains addresses of arguments supplied at a command line

    • C.

      In place of ac and av, argc and argv should be used.

    • D.

      The variables ac and av are always local to main()

    Correct Answer
    C. In place of ac and av, argc and argv should be used.
    Explanation
    The statement "In place of ac and av, argc and argv should be used" is false because ac and av are the conventional names for the arguments in the main function in C programming. argc stands for "argument count" and av stands for "argument vector," which are just alternative names for ac and av respectively.

    Rate this question:

  • 4. 

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

    • A.

      128 characters

    • B.

      256 characters

    • C.

      67 characters

    • D.

      It may vary from one operating system to another

    Correct Answer
    D. It may vary from one operating system to another
    Explanation
    The maximum combined length of command-line arguments including spaces can vary from one operating system to another. Different operating systems have different limits on the length of command-line arguments. Therefore, the maximum combined length cannot be determined without considering the specific operating system being used.

    Rate this question:

  • 5. 

    Which of the following statement is correct prototype of the malloc() function in c ?

    • A.

      Int* malloc(int);

    • B.

      Char* malloc(char);

    • C.

      Unsigned int* malloc(unsigned int);

    • D.

      Void* malloc(size_t);

    Correct Answer
    D. Void* malloc(size_t);
    Explanation
    The correct prototype of the malloc() function in C is void* malloc(size_t). This is because the malloc() function returns a void pointer (void*) which can be cast to any other pointer type. The size_t parameter is used to specify the number of bytes to allocate for the memory block. This allows for dynamic memory allocation in C, where the size of the memory block can vary at runtime.

    Rate this question:

  • 6. 

    How many times the while loop will get executed if a short int is 2 byte wide? #include<stdio.h> int main() {     int j=1;     while(j <= 255)     {         printf("%c %d\n", j, j);         j++;     }     return 0; }

    • A.

      Infinite times

    • B.

      255 times

    • C.

      256 times

    • D.

      254 times

    Correct Answer
    B. 255 times
    Explanation
    The while loop will get executed 255 times because the condition in the while loop is "j

    Rate this question:

  • 7. 

    What will function gcvt() do?

    • A.

      Convert floating-point number to a string

    • B.

      Convert vector to integer value

    • C.

      Convert 2D array in to 1D array.

    • D.

      Covert multi Dimensional array to 1D array

    Correct Answer
    A. Convert floating-point number to a string
    Explanation
    The function gcvt() is used to convert a floating-point number to a string. It takes the floating-point number as input and returns a string representation of that number. This can be useful in situations where we need to display or manipulate the floating-point number as a string, such as in printing or storing the number.

    Rate this question:

  • 8. 

    What will be the output of the program? #include<stdio.h> int main() {     int i;     i = scanf("%d %d", &i, &i);     printf("%d\n", i);     return 0; }

    • A.

      1

    • B.

      2

    • C.

      Garbage Value

    • D.

      Error: cannot assign scanf to variable

    Correct Answer
    B. 2
    Explanation
    The output of the program will be 2. This is because the scanf function is used to read input from the user, and in this case, it is being used to read two integers. The return value of scanf is the number of input items successfully matched and assigned, so in this case, it will be 2. The value of i is not relevant in this case, as it is being overwritten by the scanf function.

    Rate this question:

  • 9. 

    What will be the output of the program? #include<stdio.h> #include<math.h> int main() {     float i = 2.5;     printf("%f, %d", floor(i), ceil(i));     return 0; }

    • A.

      2, 3

    • B.

      2.000000, 3

    • C.

      2.000000, 0

    • D.

      2, 0

    Correct Answer
    C. 2.000000, 0
    Explanation
    The program uses the floor() and ceil() functions from the math.h library. The floor() function returns the largest integer less than or equal to a given value, while the ceil() function returns the smallest integer greater than or equal to a given value. In this case, the variable i is initialized as 2.5. The floor(i) will return 2, which is the largest integer less than or equal to 2.5. However, the ceil(i) will return 3, which is the smallest integer greater than or equal to 2.5. Therefore, the output of the program will be "2.000000, 0".

    Rate this question:

  • 10. 

    What will be the output of the program? #include<stdio.h> int main() {     int i;     i = printf("How r u\n");     i = printf("%d\n", i);     printf("%d\n", i);     return 0; }

    • A.

      How r u 7 2

    • B.

      How r u 8 2

    • C.

      How r u 1 1

    • D.

      Error: cannot assign printf to variable

    Correct Answer
    B. How r u 8 2
    Explanation
    The program first prints "How r u" and returns the number of characters printed, which is 8. This value is then assigned to the variable i. Then, the program prints the value of i, which is 8. Finally, it prints the value of i again, which is still 8. So, the output of the program is "How r u", followed by two lines of "8".

    Rate this question:

  • 11. 

    What will the function randomize() do in Turbo C under DOS?

    • A.

      Returns a random number.

    • B.

      Returns a random number generator in the specified range.

    • C.

      Returns a random number generator with a random value based on time.

    • D.

      Return a random number with a given seed value.

    Correct Answer
    C. Returns a random number generator with a random value based on time.
    Explanation
    The function randomize() in Turbo C under DOS will return a random number generator with a random value based on time. This means that each time the function is called, it will generate a different random value based on the current time. This ensures that the random numbers generated are not predictable and can be used for various purposes such as generating random values in a game or simulation.

    Rate this question:

  • 12. 

    Point out the error in the program? #include<stdio.h> int main() {     FILE *fp;     fp=fopen("trial", "r");     fseek(fp, "20", SEEK_SET);     fclose(fp);     return 0; }

    • A.

      Error: unrecognised Keyword SEEK_SET

    • B.

      Error: fseek() long offset value

    • C.

      No error

    • D.

      None of above

    Correct Answer
    B. Error: fseek() long offset value
    Explanation
    The error in the program is that the fseek() function is being passed a string ("20") instead of a long offset value. The fseek() function is used to set the file position indicator for the stream pointed to by the file pointer 'fp'. The third argument of fseek() should be of type long, not a string.

    Rate this question:

  • 13. 

    Point out the error in the program? #include<stdio.h> int main() {     char ch;     int i;     scanf("%c", &i);     scanf("%d", &ch);     printf("%c %d", ch, i);     return 0; }

    • A.

      Error: suspicious char to in conversion in scanf()

    • B.

      Error: we may not get input for second scanf() statement

    • C.

      No error

    • D.

      None of above

    Correct Answer
    B. Error: we may not get input for second scanf() statement
    Explanation
    The error in the program is that the format specifier in the first scanf() statement is incorrect. The variable 'i' is an int type, but the format specifier used is '%c' which is for char types. This can cause unexpected behavior or errors when trying to read input into 'i'. Additionally, there is a possibility that the second scanf() statement may not receive any input, which can also cause issues when trying to read the value into 'ch'.

    Rate this question:

  • 14. 

    To print out a and b given below, which of the following printf() statement will you use? #include<stdio.h> float a=3.14; double b=3.14;

    • A.

      Printf("%f %lf", a, b);

    • B.

      Printf("%Lf %f", a, b);

    • C.

      Printf("%Lf %Lf", a, b);

    • D.

      Printf("%f %Lf", a, b);

    Correct Answer
    A. Printf("%f %lf", a, b);
    Explanation
    The correct answer is printf("%f %lf", a, b) because the format specifier "%f" is used to print a float variable, and the format specifier "%lf" is used to print a double variable. Since "a" is a float and "b" is a double, this printf() statement will correctly print out both variables.

    Rate this question:

  • 15. 

    Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+");

    • A.

      Reading

    • B.

      Writing

    • C.

      Appending

    • D.

      Read and Write

    Correct Answer
    D. Read and Write
    Explanation
    The code is using the "r+" mode to open the file "NOTES.TXT". This mode allows both reading and writing operations to be performed on the file. Therefore, the correct answer is "Read and Write".

    Rate this question:

  • 16. 

    What is the purpose of "rb" in fopen() function used below in the code? FILE *fp; fp = fopen("source.txt", "rb");

    • A.

      Open "source.txt" in binary mode for reading

    • B.

      Open "source.txt" in binary mode for reading and writing

    • C.

      Create a new file "source.txt" for reading and writing

    • D.

      None of above

    Correct Answer
    A. Open "source.txt" in binary mode for reading
    Explanation
    The purpose of "rb" in the fopen() function is to open the file "source.txt" in binary mode for reading.

    Rate this question:

  • 17. 

    Which of the following statement is correct?

    • A.

      Strcmp(s1, s2) returns a number less than 0 if s1>s2

    • B.

      Strcmp(s1, s2) returns a number greater than 0 if s1<s2

    • C.

      Strcmp(s1, s2) returns 0 if s1==s2

    • D.

      Strcmp(s1, s2) returns 1 if s1==s2

    Correct Answer
    C. Strcmp(s1, s2) returns 0 if s1==s2
    Explanation
    The correct answer is that strcmp(s1, s2) returns 0 if s1==s2. This is because strcmp() is a function in C that compares two strings lexicographically. If the two strings are equal, strcmp() returns 0.

    Rate this question:

  • 18. 

    Which of the following statements are correct ? 1:            A string is a collection of characters terminated by '\0'. 2:            The format specifier %s is used to print a string. 3:            The length of the string can be obtained by strlen(). 4:            The pointer CANNOT work on string.

    • A.

      1, 2

    • B.

      1, 2, 3

    • C.

      2, 4

    • D.

      3, 4

    Correct Answer
    B. 1, 2, 3
    Explanation
    Statement 1 is correct because a string in C is represented as a collection of characters terminated by a null character '\0'.

    Statement 2 is correct because the format specifier %s is used to print a string in C.

    Statement 3 is correct because the strlen() function in C can be used to obtain the length of a string.

    Statement 4 is incorrect because pointers can work on strings in C.

    Rate this question:

  • 19. 

    If the size of pointer is 32 bits What will be the output of the program ? #include<stdio.h> int main() {     char a[] = "Visual C++";     char *b = "Visual C++";     printf("%d, %d\n", sizeof(a), sizeof(b));     printf("%d, %d", sizeof(*a), sizeof(*b));     return 0; }

    • A.

      10, 2 2, 2

    • B.

      10, 4 1, 2

    • C.

      11, 4 1, 1

    • D.

      12, 2 2, 2

    Correct Answer
    C. 11, 4 1, 1
    Explanation
    The size of the array 'a' is 11 because it includes the null character at the end of the string. The size of the pointer 'b' is 4 because it is a 32-bit system and pointers are typically 4 bytes in size. When we use the * operator to dereference the pointers and get the size of the characters they point to, both 'a' and 'b' are of type char, so they have a size of 1 byte. Therefore, the output of the program is "11, 4" and "1, 1".

    Rate this question:

  • 20. 

    If char=1, int=4, and float=4 bytes size, What will be the output of the program ? #include<stdio.h> int main() {     char ch = 'A';     printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));     return 0; }

    • A.

      1, 2, 4

    • B.

      1, 4, 4

    • C.

      2, 2, 4

    • D.

      2, 4, 8

    Correct Answer
    B. 1, 4, 4
    Explanation
    The program is using the sizeof() function to determine the size in bytes of different data types. The variable "ch" is of type char and therefore has a size of 1 byte. The character 'A' is also of type char and has a size of 1 byte. The number 3.14f is of type float and has a size of 4 bytes. Therefore, the output of the program will be "1, 4, 4", indicating the size of each data type in bytes.

    Rate this question:

  • 21. 

    What will be the output of the program in 16-bit platform (Turbo C under DOS) ? #include<stdio.h> int main() {     printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));     return 0; }

    • A.

      8, 1, 4

    • B.

      4, 2, 8

    • C.

      4, 2, 4

    • D.

      10, 3, 4

    Correct Answer
    B. 4, 2, 8
    Explanation
    The program uses the sizeof() function to determine the size in bytes of different data types. The first sizeof() function is used on a float value (3.0f), which is a 4-byte data type, so the output is 4. The second sizeof() function is used on a character value ('3'), which is a 1-byte data type, so the output is 1. The third sizeof() function is used on a double value (3.0), which is an 8-byte data type, so the output is 8. Therefore, the output of the program will be 4, 2, 8.

    Rate this question:

  • 22. 

    What will be the output of the program ? #include<stdio.h> #include<string.h> int main() {     static char s[] = "Hello!";     printf("%d\n", *(s+strlen(s)));     return 0; }

    • A.

      8

    • B.

      0

    • C.

      16

    • D.

      Error

    Correct Answer
    B. 0
    Explanation
    The program will output 0. The variable s is a static character array containing the string "Hello!". The expression *(s+strlen(s)) is equivalent to *(s+6), which is the value at the memory location s+6. Since the string "Hello!" has a length of 6, this expression is accessing the memory location just after the null character at the end of the string. In this case, the value at that memory location happens to be 0. So, when we print *(s+strlen(s)), it will print 0.

    Rate this question:

  • 23. 

    What will be the output of the program ? #include<stdio.h> int main() {     printf(5+"Good Morning\n");     return 0; }

    • A.

      Good Morning

    • B.

      Good

    • C.

      M

    • D.

      Morning

    Correct Answer
    D. Morning
    Explanation
    The program will output "Morning". This is because the expression "5+"Good Morning" is equivalent to "Good Morning" + 5, which results in the starting address of the string being incremented by 5. Therefore, the program will print the string starting from the 6th character, which is "Morning".

    Rate this question:

  • 24. 

    What will be the output of the program ? #include<stdio.h> #include<string.h> int main() {     printf("%d\n", strlen("123456"));     return 0; }

    • A.

      6

    • B.

      12

    • C.

      7

    • D.

      2

    Correct Answer
    A. 6
    Explanation
    The program uses the strlen() function to determine the length of the string "123456". Since the string has 6 characters, the output of the program will be 6.

    Rate this question:

  • 25. 

    What will be the output of the program ? #include<stdio.h> int main() {     char p[] = "%d\n";     p[1] = 'c';     printf(p, 65);     return 0; }

    • A.

      A

    • B.

      A

    • C.

      C

    • D.

      65

    Correct Answer
    A. A
    Explanation
    The correct answer is "A".

    In the given program, the character array "p" is initialized with the format specifier "%d". Then, the character at index 1 of the array "p" is changed to 'c'.

    When the printf function is called with the array "p" as the format string and the integer value 65 as the argument, it will print "65" as the output.

    Therefore, the output of the program will be "A".

    Rate this question:

  • 26. 

    What will be the output of the program ? #include<stdio.h> #include<string.h> int main() {     char str1[20] = "Hello", str2[20] = " World";     printf("%s\n", strcpy(str2, strcat(str1, str2)));     return 0; }

    • A.

      Hello

    • B.

      World

    • C.

      Hello World

    • D.

      WorldHello

    Correct Answer
    C. Hello World
    Explanation
    The program uses the strcpy() and strcat() functions to concatenate the strings str1 and str2. The strcat() function appends str2 to str1, resulting in the string "Hello World". Then, the strcpy() function copies the concatenated string into str2. Therefore, the output of the program is "Hello World".

    Rate this question:

  • 27. 

    What will be the output of the program? #include<stdio.h> #include<stdlib.h> int main() {     int i=0;     i++;     if(i<=5)     {         printf("IndiaBIX");         exit(1);         main();     }     return 0; }

    • A.

      Prints "IndiaBIX" 5 times

    • B.

      Function main() doesn't calls itself

    • C.

      Infinite loop

    • D.

      Prints "IndiaBIx"

    • E.

      Option 5

    Correct Answer
    D. Prints "IndiaBIx"
    Explanation
    The program starts by initializing the variable i to 0. Then, it increments i by 1. The program then checks if i is less than or equal to 5. Since i is 1, the condition is true.

    Inside the if statement, the program prints "IndiaBIX" and exits with a status of 1. However, before exiting, the program calls the main() function recursively.

    This means that the program will continue to execute from the beginning, incrementing i by 1 each time. Since there is no condition to stop the recursion, it will result in an infinite loop.

    Therefore, the program will continuously print "IndiaBIX" and will not terminate.

    Rate this question:

  • 28. 

    What will be the output of the program? #include<stdio.h> int fun(int(*)()); int main() {     fun(main);     printf("Hi\n");     return 0; } int fun(int (*p)()) {     printf("Hello ");     return 0; }

    • A.

      Infinite loop

    • B.

      Hi

    • C.

      Hello Hi

    • D.

      Error

    Correct Answer
    C. Hello Hi
    Explanation
    The program will output "Hello Hi". The function `fun` is called in the `main` function with `main` as an argument. Inside the `fun` function, "Hello " is printed. Then, in the `main` function, "Hi" is printed. Therefore, the output will be "Hello Hi".

    Rate this question:

  • 29. 

    What will be the output of the program? #include<stdio.h> int fun(int); int main() {     float k=3;     fun(k=fun(fun(k)));     printf("%f\n", k);     return 0; } int fun(int i) {     i++;     return i; }

    • A.

      5.000000

    • B.

      3.000000

    • C.

      Garbage value

    • D.

      4.000000

    Correct Answer
    A. 5.000000
    Explanation
    The program defines a function `fun` that takes an integer as input and increments it by 1. In the `main` function, a float variable `k` is initialized with the value 3. The `fun` function is called three times on `k` in a nested manner: `fun(k=fun(fun(k)))`. The innermost call to `fun(k)` increments `k` by 1, making it 4. Then, the next call to `fun` increments 4 by 1, making it 5. Finally, the outermost call to `fun` assigns the value 5 to `k`. Therefore, the output of the program will be 5.000000.

    Rate this question:

  • 30. 

    .   Point out the error in the program f(int a, int b) {     int a;     a = 20;     return a; }

    • A.

      Missing parenthesis in return statement

    • B.

      The function should be defined as int f(int a, int b)

    • C.

      Redeclaration of a

    • D.

      None of above

    Correct Answer
    C. Redeclaration of a
    Explanation
    The error in the program is the redeclaration of the variable "a" inside the function. The variable "a" is already declared as a parameter in the function definition, so redeclaring it inside the function is not allowed and causes a compilation error.

    Rate this question:

Related Topics

Back to Top Back to top
Advertisement