Explain a Type Qualifiers
Q) List four type qualifiers.
- A type qualifier is written along with declaring a variable. If specifies the additional qualification of the variable. Following are the type qualifiers in C:
- const signed unsigned long short volatile
|Image Source ~ Crafted With ©Ishwaranand – 2020 ~ Image by ©Ishwaranand|
- unsigned int K;
- unsigned specify that we want the variable without a sign. It does not allow negative values. So variable ‘K’ can contain only a positive value.
Q) Explain with an example of how constants are created.
- A constant is an entity whose value cannot be changed during the execution of the program. In C constants are created using const keyword. Following is the syntax for creating constantly.
- Const data_type constant_name = value;
- const int MAX = 30;
- const float PI = 3.14;
Q) Write a program to accept the radius of the circle. Calculate & display the area & circumference of the circle
const float PI=3.14; /* PI is constant */
float area, circum;
printf(“enter values of radius : “);
area = PI*r*r;
circum = 2*PI*r;
printf(“nArea = %f”, area);
printf(“nCircumference = %f”, circum);
Enter values of radius: 10
Area = 314.000000
Circumference = 62.800000
Last updated on Sunday - May 21st, 2023