• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Operators

Question 1

 

#include <stdio.h>

int main()
{
    int i = 1, 2, 3;
    
    printf("%d", i);
    
    return 0;
}


  • 1
  • 3
  • Garbage value
  • Compile time error

Question 2

#include <stdio.h>

int main()
{
    int i = (1, 2, 3);
    
    printf("%d", i);
    
    return 0;
}

  • 1
  • 3
  • Garbage value
  • Compile time error

Question 3

 
#include <stdio.h>

int main()
{
    int i;
    
    i = 1, 2, 3;
    printf("%d", i);
    
    return 0;
}
  • 1
  • 3
  • Garbage value
  • Compile time error

Question 4

What is the output of below program?

C
#include <stdio.h>
int foo(int* a, int* b)
{
    int sum = *a + *b;
    *b = *a;
    return *a = sum - *b;
}
int main()
{
    int i = 0, j = 1, k = 2, l;
    l = i++ || foo(&j, &k);
    printf(\"%d %d %d %d\", i, j, k, l);
    return 0;
}
  • 1 2 1 1

  • 1 1 2 1

  • 1 2 2 1

  • 1 2 2 2

Question 5

C
#include <stdio.h>
int main()
{
    int i = 5, j = 10, k = 15;
    printf(\"%d \", sizeof(k /= i + j));
    printf(\"%d\", k);
    return 0;
}
Assume size of an integer as 4 bytes. What is the output of above program?
  • 4 1
  • 4 15
  • 2 1
  • Compile-time error

Question 6

C
#include <stdio.h>
int main()
{
    //Assume sizeof character is 1 byte and sizeof integer is 4 bytes
    printf(\"%d\", sizeof(printf(\"GeeksQuiz\")));
    return 0;
}
  • GeeksQuiz4
  • 4GeeksQuiz
  • GeeksQuiz9
  • 4
  • Compile-time error

Question 7

Output of following program? C
#include <stdio.h>
int f1() { printf (\"Geeks\"); return 1;}
int f2() { printf (\"Quiz\"); return 1;}

int main()
{
  int p = f1() + f2();
  return 0;
}
  • GeeksQuiz
  • QuizGeeks
  • Compiler Dependent
  • Compiler Error

Question 8

What is the output of following program? C
#include <stdio.h>

int main()
{
   int a = 1;
   int b = 1;
   int c = a || --b;
   int d = a-- && --b;
   printf(\"a = %d, b = %d, c = %d, d = %d\", a, b, c, d);
   return 0;
}
  • a = 0, b = 1, c = 1, d = 0
  • a = 0, b = 0, c = 1, d = 0
  • a = 1, b = 1, c = 1, d = 1
  • a = 0, b = 0, c = 0, d = 0

Question 9

C
#include <stdio.h> 
int main() 
{ 
  int a = 10, b = 20, c = 30; 
  if (c > b > a) 
    printf(\"TRUE\"); 
  else
    printf(\"FALSE\"); 
  return 0; 
}
  • TRUE
  • FALSE
  • Compiler Error
  • Output is compiler dependent

Question 10

C
#include<stdio.h> 
int main() 
{ 
  char *s[] = { \"knowledge\",\"is\",\"power\"}; 
  char **p; 
  p = s; 
  printf(\"%s \", ++*p); 
  printf(\"%s \", *p++); 
  printf(\"%s \", ++*p); 
  
  return 0; 
}
  • is power
  • nowledge nowledge s
  • is ower
  • nowledge knowledge is

There are 41 questions to complete.

Last Updated :
Take a part in the ongoing discussion