Operators
Operators
Operators in ‘C’
#include <stdio.h>
int main(void)
{
float a=5.0,b=2.0,c;
c=a % b;
printf("%f",c);
return 0;
}
#include <stdio.h>
int main(void)
{
float a=5.0,b=2.0,c;
c=a % b;
printf("%f",c);
return 0;
}
#include <stdio.h>
int main(void)
{
int a=5,b=2,c;
c=a++ + ++b + b++ + ++a + a++ + ++b;
printf("%d",c);
return 0;
}
#include <stdio.h>
int main(void)
{
int a=5,b=2,c;
c=a++ + ++b + b++ + ++a + a++ + ++b;
printf("%d",c);
return 0;
}
#include <stdio.h>
int main(void)
{
int a=5,b=3,c;
c=a-- + --a + b-- + --b + --b + --a;
printf("%d",c);
return 0;
}
#include <stdio.h>
int main(void)
{
int a=5,b=3,c;
c=a-- + --a + b-- + --b + --b + --a;
printf("%d",c);
return 0;
}
#include <stdio.h>
int main(void)
{
int a=5;
printf("%d%d%d",a++,++a,++a);
return 0;
}
#include <stdio.h>
int main(void)
{
int a=5;
printf("%d%d%d",a++,++a,++a);
return 0;
}
#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
#include <stdio.h>
int main()
{
int a = 4;
printf("%d", (++a)++);
return 0;
}
| Bitwise Or
^ Bitwise XOR
~ Bitwise NOT
Bitwise Operator:
points to remember-
1.Left and right shift operators should not be used for negative numbers.
2.if the number is shifted more than the size of integer the behavior is undefined.
3.The bitwise operator should not be used in place of logical operators.
Technical Training (C Basics)
#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
1 #include <stdio.h>
2 int a = 2; What would be the output of the above code ? Choose
3 int a; the correct option.
4 int main(void) { A. 2 0 1 2 3 B. 2 2 2 2 3
5 printf("%d", a);
6 int a; C. 2 1 1 2 2 D. Compiler error
7 for(int i = 0 ; i < 3 ; i++ )
8 {
9 printf("%d", a);
10 a++;
11 }
12 printf("%d", a);
13 return 0;
14 }
Technical Training (C Basics) TCS
1 #include <stdio.h>
2 int a = 2; What would be the output of the above code ? Choose
3 int a; the correct option.
4 int main(void) { A. 2 0 1 2 3 B. 2 2 2 2 3
5 printf("%d", a);
6 int a; C. 2 1 1 2 2 D. Compiler error
7 for(int i = 0 ; i < 3 ; i++ )
8 {
9 printf("%d", a);
10 a++;
11 }
12 printf("%d", a);
13 return 0;
14 }
Technical Training (C Basics) Capegemini
1 #include <stdio.h>
2 int a = 12; What would be the output of the above code ? Choose
3 int main(void) { the correct option.
4 for(int j = 0; j <= 1; j++) A. 4 B. 12
5 {
6 int a = 4; C. 5 D. Compiler error
7 a++;
8 }
9 printf("%d" , a);
10 return 0;
11 }
Technical Training (C Basics) Capegemini
1 #include <stdio.h>
2 int a = 12; What would be the output of the above code ? Choose
3 int main(void) { the correct option.
4 for(int j = 0; j <= 1; j++) A. 4 B. 12
5 {
6 int a = 4; C. 5 D. Compiler error
7 a++;
8 }
9 printf("%d" , a);
10 return 0;
11 }
Technical Training (C Basics) TCS
1 #include <stdio.h>
2 int main(void) {
3 for(int i = 0; i < 2; i++)
4 {
5 static int a = 4;
6 a++;
7 }
8 printf("%d", a);
9 return 0;
10 }
1 #include <stdio.h>
2 int main(void) {
3 for(int i = 0; i < 2; i++)
4 {
5 static int a = 4;
6 a++;
7 }
8 printf("%d", a);
9 return 0;
10 }
1 #include <stdio.h> What would be the output of the above code ? Choose
2 int a; the correct option.
3 int main(void) {
A. 0 1 B. 2 3
4 {
5 a = 2; C. 3 4 D. Error
6 }
7 for(int i = 0; i < 2; i++)
8 {
9 a++ ;
10 printf("%d " , a);
11 }
12 return 0 ;
13 }
Technical Training (C Basics) Capegemini
1 #include <stdio.h> What would be the output of the above code ? Choose
2 int a; the correct option.
3 int main(void) {
A. 0 1 B. 2 3
4 {
5 a = 2; C. 3 4 D. Error
6 }
7 for(int i = 0; i < 2; i++)
8 {
9 a++ ;
10 printf("%d " , a);
11 }
12 return 0 ;
13 }
Technical Training (C Basics) Infosys
1 #include <stdio.h> What would be the output of the above code ? Choose
2 int main(void) { the correct option.
3 int x = 1 ;
A. 1 10 0 B. 1 10 1
4 printf("%d", x ); {
5 int x = 10; C. 1 10 10 D. Error
6 printf("%d", x ); {
7 x;
8 printf("%d", x );
9 }
10 }
11 return 0;
12 }
Technical Training (C Basics) Infosys
1 #include <stdio.h> What would be the output of the above code ? Choose
2 int main(void) { the correct option.
3 int x = 1 ;
A. 1 10 0 B. 1 10 1
4 printf("%d", x ); {
5 int x = 10; C. 1 10 10 D. Error
6 printf("%d", x ); {
7 x;
8 printf("%d", x );
9 }
10 }
11 return 0;
12 }
Technical Training (C Basics) Accenture
1 #include <stdio.h> What would be the output of the above code ? Choose
2 int main(void) { the correct option.
3 int a = 5;
A. 3 B. 4
4 int s = a-- || a-- && 4;
5 printf("%d", s); C. 2 D. 1
6 }
Technical Training (C Basics) Infosys
1 #include <stdio.h> What would be the output of the above code ? Choose
2 int main(void) { the correct option.
3 int a = 5;
A. 3 B. 4
4 int s = a-- || a-- && 4;
5 printf("%d", s); C. 2 D. 1
6 }
Technical Training (C Basics) Accenture