0
How this code works?
#include<stdio.h> #include<conio.h> void main() { char s[]="This is my character array"; int a=5; printf(a>10?"%s":"%s",s); } Output:This is my character array
4 Respostas
+ 3
a>10? “%s” : “%s”
This is a ternary operator.
An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c".
In this code is a bit useless because it will print the string anyways.
+ 1
Ur-Wellwisher yes this is correct u can use as many u want
0
According to standard your program will give you errors becz void main is no longer supportable in c cpp u can use int main and with return int u need to return any value at the end
Inside body u have define one char array and in print statement u have written a>10 if this will be ture then fist case will be execute otherwise second one will be execute this is ternary operator if u dont know about it u can read .
%s work as a format specifier in c language if u have to print any value then u need to use format specifiers for Integer value%d for char %c for string %s and simply s will be printed on your Console
0
Is this print statement is correct?
If so how many we can use it?