Write the difference between float and double
Its size is 4 bytes Its size is 8 bytes
This data type supports This data type supports up to 15
up to 7 digits of storage. digits of storage.
For float data type, the For double data type, the format
format specifier is %f. specifier is %lf.
It requires less memory
It occupies more memory space
space
Conditional operator(ternary operator)
We use the ternary operator in C to run one code
when the condition is true and another code when
the condition is false
Syntax :
Testcondition?expression1:expression 2
For example,
(age>=18) ? printf(“can vote”) : print f(“cannot vote”);
Here, when the age is greater than or equal to 18,
Can Vote is printed. Otherwise, Cannot Vote is
printed.
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
(age >= 18) ? printf("You can vote") : printf("You cannot vote");
return 0;
}
output:
Enter your age : 12
you cannot voteS
ASCII stands for American Standard Code for
Information Interchange