Operators: Main (Int X 5 Float K 0.8 Printf ("%d",sizeof (X+K) ) Printf ("%d",sizeof (X 7) ) Printf ("%D",X) )
Operators: Main (Int X 5 Float K 0.8 Printf ("%d",sizeof (X+K) ) Printf ("%d",sizeof (X 7) ) Printf ("%D",X) )
main()
{
int x=5;
float k=0.8;
printf(“%d”,sizeof(x+k));
printf(“%d”,sizeof(x=7));
printf(“%d”,x);
}
O/P: 4 2 5
EXPLANATION: The first printf() statement will print 4 because when
we add two different data types(in this case int and float) we will get the size of the
data type which occupies more bytes
main()
{
printf(“%d %d %d %d”,23,023,0x23,0X23);
}
O/P-23 19 35 35
main()
{
printf(“%d %o %x”,72,72,72);
}
O/P-72 110 48
main()
{
int s=90000;
int r=40000;
printf(“%d\t%d”,s,r);
}
Explanation:
(i) If 32767 < value < 65535, ans = value – 65536
(ii) If value > 65535, ans = value % 65536
main()
{
int a=33300;
float b=3.4e100;
printf(“a=%d b=%f”,a,b);
printf(“%d%d”,sizeof(a),sizeof(b));
}
O/P- 65 A
main()
{
int a=1234;
printf(“%d\n”,(printf(“%d\n”,printf(“%d\n”,a))));
}
O/P-1234
4
1
main()
{
int x;
x=-3+4-7*8/5%10;
printf(“x= %d”,x);
}
O/P- x = 0
main()
{
int a=300*300/300;
printf(“%d”,a);
}
O/P-81
main()
{
char a=‘A’;
float p=8.0;
printf(“%d\n”,sizeof(8));
printf(“%d%d\n”,sizeof(a),sizeof(‘A’));
printf(“%d%d”,sizeof(p),sizeof(8.0));
}
O/P- 2
12
48
main()
{
float a=5,b=7;
int c;
c=a%b;
printf(“%d”,c);
}
O/P-Errors
Explanation:Modulus operator cannot be applied to floating-point variable
int main()
{
int x=5,a;
a=x++ + x++ + x++;
printf(“%d %d”,x,a);
}
O/P-8 15
int main()
{
int x=5,a;
a=x- - + x- - + x- -;
printf(“%d %d”,x,a);
}
O/P- 2 15
int main()
{
int x=5,a;
a=++x + ++x + ++x;
printf(“%d %d”,x,a);
}
O/P- 8 24
int main()
{
int x=5,a;
a=- -x + - -x + - -x;
printf(“%d %d”,x,a);
}
O/P- 2 6
main()
{
int a,b;
a=7;
b=a++ + ++a;
printf(“%d %d”,a,b);
}
O/P-9 16
main()
{
int a=5,b=7;
c=a- - * - -a * b++ + ++a * - -b;
printf (“%d%d%d”, a,b,c);
}
O/P-4 7 180
int main()
{
int a=5;
printf(“%d%d%d”, ++a, a--, a++);
}
O/P-6 6 5
int main()
{
printf(NULL);
return(0);
}
(c)No Output
O/P-%
% is a format specifier and it prints %. The excess arguments are merely ignored i.e. 7.
int main()
{
printf("d%",8);
return(0);
}
O/P-d%
int main()
{
printf("Hi Friends"+3);
return(0);
}
O/P-Friends
int main()
{
printf("Work" "Hard");
return(0);
}
O/P-WorkHard
int main()
{
int val=5;
printf("%d %d %d %d",val,--val,++val,val--);
return(0);
}
O/P-Compiler dependant
int main()
{
int val=5;
val=printf("C") + printf("Skills");
printf("%d",val);
return(0);
}
O/P-CSkills7
int main()
}
int val=5;
printf("%d",5+val++);
return(0);
{
O/P-Compile-Time Error
int main()
{
printf("%d %d %d",5,!5,25-!25);
return(0);
}
O/P-5 0 25
Negation (!) of non-zero value always returns 0 (zero). Thus the arguments
to the printf will be 5 0 25-0. Thus it prints 5 0 25
int main()
{
int a=500,b=100,c=30,d=40,e=19;
a+=b-=c*=d/=e%=5;
printf("%d %d %d %d %d",a,b,c,d,e);
return(0);
}
O/P-100 300 3
O/P-a=A b= c=B
While accepting we're expecting NO whitespaces between the three different inputs
i.e. characters but O/P-a=A b= c=B we've encountered characters in the actual input.
main()
{
int p,q;
printf(“Accept the values for p and q”);
scanf(“ %d%d ”, p, q);
printf(“p=%d q=%d”,p,q);
}
O/P:Segmentation Fault
int main()
{
int a=5;
printf(“%d”,5++);
}
O/P-Error
L-Value required
int main()
{
int x=6>>1;
printf(“%d”,x);
}
O/P: 3
int main()
{
int x=6<<1;
printf(“%d”,x);
}
O/P: 12
int main()
{
int a=3,b;
b=a+++5;
printf(“%d %d”,a,b);
}
O/P- 4 8