(a)
#include<stdio.h>
int main()
{
int tag = 0, code = 1 ;
if ( tag == 0 )
( code > 1 ? printf ( "\nHello" ) ? printf ( "\nHi" ) ) ;
else
printf ( "\nHello Hi !!" ) ;
return 0;
}
Error:
Error: ?
operator always comes with an :
, which is missing.
(b)
#include<stdio.h>
int main()
{
int ji = 65 ;
printf ( "\nji >= 65 ? %d : %c", ji ) ;
return 0;
}
No Error.
(c)
#include<stdio.h>
int main()
{
int i = 10, j ;
i >= 5 ? ( j = 10 ) : ( j = 15 ) ;
printf ( "\n%d %d", i, j ) ;
return 0;
}
No Error.
(d)
#include<stdio.h>
int main()
{
int a = 5 , b = 6 ;
( a == b ? printf( "%d",a) ) ;
return 0;
}
Error: ?
operator always comes with an :
, which is missing.
(e)
#include<stdio.h>
int main()
{
int n = 9 ;
( n == 9 ? printf( "You are correct" ) ; : printf( "You are wrong" ) ;) ;
return 0;
}
Error: There should not be ;
after printf statements.
(f)
#include<stdio.h>
int main()
{
int kk = 65 ,ll ;
ll = ( kk == 65 : printf ( "\n kk is equal to 65" ) : printf ( "\n kk is not equal to 65" ) ) ;
printf( "%d", ll ) ;
return 0;
}
Error: :
is used without any ?
operator.
(g)
#include<stdio.h>
int main()
{
int x = 10, y = 20 ;
x == 20 && y != 10 ? printf( "True" ) : printf( "False" ) ;
return 0;
}
No Error.