C Operators - Aptitude Questions & Answers

C programming Operators Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on various Operators like Arithmetic, Assignment, Compound Assignment, Relation Operators etc.

List of C programming Operators Aptitude Questions and Answers

1) What will be the output of following program ?
#include <stdio.h>
void main()
{   
    printf("value is = %d",(10++));
}
  1. 10
  2. 11
  3. 0
  4. ERROR

2) What will be the output of following program ?
#include <stdio.h>
void main()
{   
	const char var='A';
	++var;
	printf("%c",var);
}
  1. B
  2. A
  3. ERROR
  4. 66


3) What will be the output of following program ?
#include <stdio.h>
void main()
{   
	int x=10;
	x+=(x++)+(++x)+x;
	printf("%d",x);
}
  1. 44
  2. 45
  3. 46
  4. 47

4) What will be the output of following program ?
#include <stdio.h>
void main()
{   
	int a=10,b=2,x=0;
	x=a+b*a+10/2*a;
	printf("value is =%d",x);
}
  1. valie is =1250
  2. value is =80
  3. value is =125
  4. ERROR

5) What will be the output of following program ?
#include <stdio.h>
void main()
{   
	unsigned short var='B';
	var+=2;
	var++;
	printf("var : %c , %d ", var,var);
}
  1. var : E, 69
  2. var : E, 68
  3. var : D, 68
  4. var : D, 69


6) What will be the output of following program ?
#include <stdio.h>
void main()
{   
	char var=10;
	printf("var is = %d",++var++);
}
  1. ERROR : Can not modify var.
  2. ERROR : L-Value required.
  3. ERROR : Expression syntax.
  4. 12

7) What will be the output of following program ?
#include <stdio.h>
void main()
{   
	int x=(20 || 40 ) && (10);
	printf("x= %d",x);
}
  1. x= 60
  2. x= 70
  3. x= 0
  4. x= 1

8) What will be the output of following program ?
#include <stdio.h>
void main()
{
	int x;
	x= (printf("AA")||printf("BB"));
	printf("%d",x);
	printf("\n");

	x= (printf("AA")&&printf("BB"));
	printf("%d",x);
}
  1. AABB1
    AABB1
  2. 1
    1
  3. AABB1
    AA1
  4. AA1
    AABB1


9) What will be the output of following program ?
#include <stdio.h>
void main()
{
   int a=3,b=2;
   a=a==b==0;
   printf("%d,%d",a,b);
}
  1. 1,2
  2. 3,2
  3. 0,0
  4. 2,3

10) What will be the output of following program ?
#include <stdio.h>
void main(){
   int intVar=20,x;
   x= ++intVar,intVar++,++intVar;
   printf("Value of intVar=%d, x=%d",intVar,x);
}
  1. Value of intVar=23, x=21
  2. Value of intVar=23, x=23
  3. Value of intVar=21, x=21
  4. ERROR

11) What will be the output of following program ?
#include <stdio.h>
int main(){
    char val=250;
    int	 ans;
    ans= val+ !val + ~val + ++val;
    printf("%d",ans);
    return 0;
}
  1. -5
  2. -6
  3. 0
  4. 6


12) What will be the output of following program ?
#include <stdio.h>
int main(){
   float a;
   (int)a= 10;
   printf("value of a=%d",a);
   return 0;
}
  1. value of a=10
  2. value of a=10.000000
  3. value of a=0
  4. L-value required.

13) What will be the output of following program ?
#include <stdio.h>
int main(){
	int x;
	x=100,30,50;
	printf("x=%d\n",x);
	x=(100,30,50);
	printf("x=%d\n",x);
	return 0;
}
  1. x=100
    x=100
  2. x=100
    x=50
  3. x=50
    x=50
  4. x=50
    x=100

14) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int i=-1,j=-1,k=0,l=2,m;
	m=i++&&j++&&k++||l++;
	printf("%d %d %d %d %d",i,j,k,l,m);
	return 0;
}
  1. 0 0 1 2 1
  2. 0 0 1 3 2
  3. 0 0 1 3 1
  4. 0 1 1 3 1

15) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int var;
	var=- -10;
	printf("value of var= %d\n",var);
	var=+ +10;
	printf("value of var= %d\n",var);
	return 0;
}
  1. ERROR
  2. value of var= -10
    value of var= 10
  3. value of var= 10
    value of var= 10
  4. value of var= 10
    value of var= 11

16) What will be the value of x and y ?
#include <stdio.h>
int main()
{
    int x,y;
    
    x=(100,200);
    y=100,200;
    
    printf("x=%d,y=%d",x,y);

    return 0;
}
  1. x=100,y=200
  2. x=200,y=200
  3. ERROR
  4. x=200,y=100

17) Arrange the operators according to their precedence: +, %, ->, =
  1. ->, %, +, =
  2. =, +, %, ->
  3. %, +, =, ->
  4. %, ->, =, +





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.