Constants ka matlab hota hai jo kabhi change na ho, like 1, 2, 3, 4 and so on. Ye sab maths ke constants hote hai kioki inki values kabhi bhi change nhi ho sakti ye ek universal truth hota hai. Isi tarah se C language mein bhi constants hote hai jinki value ek baar assign karne ke baad change nhi ho sakti.
Constants
Constants fixed values hoti hai jo ki kabhi change nhi hoti during the execution of progam. Constants alag-alag types ke hote hai:
Types of Constants:
- Integer Constants: Integer Constants mein whole numbers hote hai without fractional part(e.g.,
10,-20,100) - Floating Point Constants: Aise numbers jisme Decimal Values bhi include hoti hai(e.g.,
3.14,-0.987) - Character Constants: Ek single character jo ki single quotes mein enclosed hota hai(e.g.,
'A','5') - String Constants: Characters ke sequence jo ki double quotes mein enclosed hota hai(e.g.,
"Hello World") - Symbolic Constants: Aise constants jo symbol use karte hai(eg.
#defineorconstkeyword)
Example of Constants in C:
#include <stdio.h>
#define PI 3.14159 // Symbolic constant
int main() {
const int AGE = 25; // Constant using 'const' keyword
printf("Value of PI: %f", PI);
printf("Age: %d", AGE);
return 0;
}
Comments (0)
Please login to leave a comment.
No comments yet. Be the first to comment!