0% found this document useful (0 votes)
5 views4 pages

Cprogramming

The document outlines the differences between the float and double data types in C programming, noting that float is 4 bytes and supports up to 7 digits, while double is 8 bytes and supports up to 15 digits. It also explains the use of the conditional (ternary) operator in C, providing syntax and an example for determining if a person can vote based on their age. Additionally, it briefly mentions ASCII as the American Standard Code for Information Interchange.

Uploaded by

Sk Shetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Cprogramming

The document outlines the differences between the float and double data types in C programming, noting that float is 4 bytes and supports up to 7 digits, while double is 8 bytes and supports up to 15 digits. It also explains the use of the conditional (ternary) operator in C, providing syntax and an example for determining if a person can vote based on their age. Additionally, it briefly mentions ASCII as the American Standard Code for Information Interchange.

Uploaded by

Sk Shetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 4

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

You might also like