C Programming Quiz: Output Of C Programs! Trivia

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 Shamil
S
Shamil
Community Contributor
Quizzes Created: 1 | Total Attempts: 252
| Attempts: 252 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. The function which is used to move the file pointer to any desired location within a file?

Explanation

The fseek() function is used to move the file pointer to any desired location within a file. It allows us to set the position indicator of the file stream to a specific offset from a reference point. This reference point can be the beginning, end, or current position of the file. By using fseek(), we can easily navigate through a file and perform operations at specific positions.

Submit
Please wait...
About This Quiz
C Programming Quiz: Output Of C Programs! Trivia - Quiz

“C” is a computer programming language, which supports structured programming, recursion, and lexical variable scope. It first appeared in 1972 and variations of it are still used prominently... see moretoday. What do you know about it? see less

2. Which of the following is not derived data type in c?

Explanation

An enumeration is not a derived data type in C. Derived data types are created by combining or modifying existing data types. Examples of derived data types in C include arrays, functions, and pointers. However, an enumeration is a user-defined data type that consists of a set of named values. It is used to define a list of constants that can be assigned to a variable. Therefore, the correct answer is enumeration.

Submit
3.
#include<stdio.h>
int main()
{
    int i = 1;
    switch(i)
    {
        printf("Hello\n");
        case 1:
            printf("Hi\n");
            break;
        case 2:
            printf("\nBye\n");
            break;
    }
    return 0;
}

Explanation

The code provided will not compile successfully due to a syntax error. The printf statement "Hello" is placed outside of any case block, which is not allowed in a switch statement. Therefore, the code will produce a compilation error.

Submit
4. What will be the output when you will execute following c code? #include<stdio.h> void main(){ char arr[7]="Network"; printf("%s",arr); }

Explanation

The output of the given C code will be "Network". The character array "arr" is initialized with the string "Network" which is 7 characters long. When the printf statement is executed, it will print the string stored in the "arr" array. Therefore, the output will be "Network" and not garbage value.

Submit
5. #include<stdio.h> int main(){ int a=-20; int b=-3; printf("%d",a%b); return 0; }

Explanation

The code snippet defines two variables, 'a' and 'b', with values -20 and -3 respectively. The expression 'a%b' calculates the remainder when 'a' is divided by 'b'. In this case, -20 divided by -3 gives a quotient of 6 and a remainder of -2. Therefore, the output of the program will be -2.

Submit
6. #include<stdio.h> int main(){  int a=15,b=10,c=5;  if(a>b>c )    printf("True");  else    printf("False"); return 0; }

Explanation

The code snippet compares three variables a, b, and c using the greater than operator (>). Since 15 is not greater than 10, the condition in the if statement evaluates to false. Therefore, the code will execute the else block and print "False".

Submit
7. #include<stdio.h> int main(){  const int i=5;  i++;  printf("%d",i); return 0; }

Explanation

The given code will result in a compiler error. This is because the variable "i" is declared as a constant using the "const" keyword, which means its value cannot be changed. However, in the code, there is an attempt to increment the value of "i" using the "i++" statement, which is not allowed for a constant variable. Therefore, the code will not compile successfully.

Submit
8. )#include void call(int,int,int); int main(){  int a=10; call(a,a++,++a); return 0; } void call(int x,int y,int z){  printf("%d %d %d",x,y,z); }

Explanation

The correct answer is 12 11 11. In the main function, the variable a is initially assigned the value 10. The call function is then called with the arguments a, a++, and ++a.

When the call function is executed, the values of the arguments are passed to the parameters x, y, and z respectively. The value of a is 12 at this point because of the pre-increment operation (++a) in the argument list.

However, the post-increment operation (a++) in the argument list causes the value of a to be incremented after it is passed to the call function. Therefore, the value of y is 11.

The value of x is still 10 because it was passed by value before any increment operations.

So, the output of the call function is 12 11 11.

Submit
9. # include<stdio.h> # define a 10 void foo(); main() {    printf("%d..",a);    foo();    printf("%d",a); } void foo() {    #undef a    #define a 50 }

Explanation

The code first defines a constant variable "a" with a value of 10 using the "#define" directive. It then calls the "foo()" function, which undefines the previous definition of "a" and redefines it with a new value of 50. However, since the "foo()" function is called after the first printf statement, the first printf statement will still print the original value of "a", which is 10. Therefore, the output will be "10..10".

Submit
10. #include<stdio.h> int main(){  char *url="c:\tc\bin\rw.c";  printf("%s",url); return 0; }

Explanation

The given code is a C program that prints the value of the variable "url" using the printf function. The variable "url" is assigned the value "c:\tc\bin\rw.c". The printf function then prints this value, which is "w.c in". Therefore, the correct answer is "w.c in".

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
  • Nov 04, 2011
    Quiz Created by
    Shamil
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
The function which is used to move the file pointer to any desired...
Which of the following is not derived data type in c?
#include<stdio.h>...
What will be the output when you will execute following c code?...
#include<stdio.h>...
#include<stdio.h>...
#include<stdio.h>...
)#include...
# include<stdio.h>...
#include<stdio.h>...
Alert!

Advertisement