Constants & their rules | keywords | operators | #Tut-02
Content to be covered..
1. Constants
2. Rules to declare the constants
3. Keywords
4. Types of instruction
4. Operators
Constants
Constant in the program is something what that does not change throughout the program.
Sometimes we need such a values in our program that should be remain as it is, so in such situation we
simply define constants.
In the fig. there are different types of constants are given. Most of the time we use integer and real constants.
Rules to declare constants
As we seen rules to declare the variables, there are some rules to declare the constants also.
lets see what are they..?
Code Snippet :
#include<stdio.h>
int main(){
// integer constant
const int a = -133;
printf("%d\n", a);
// a = 4; --> cannot change as 'a' is a constant
// floating point constant
const float pi = 3.14;
printf("pi = %f\n", pi);
// pi = 23.234; cannot change as 'pi' is a constant
// character constant
const char ch = 'k';
printf("character = %c", ch);
// ch = 'o'; --> cannot change as 'ch' is a constant
// const char ch = 'abc'; --> throws an error
return 0;
}
Keywords
Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier.
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
continue | for | signed | void |
do | if | static | while |
default | goto | sizeof | volatile |
const | float | short | unsigned |
Types of instruction
There are several types of instruction in a C programming.
- Type declaration instruction
- Input/Output instruction
- Arithmetic instruction
- Control instruction
#include<stdio.h>
int main(){
// type declaration instruction
float number;
// char c;
double d;
// arithmetic instruction
int a=10, b=20, c, sum;
c = a + b;
printf("c = %d\n", c);
return 0;
}
Operators
An operator is a symbol which operates on a variable or value.
Thanks bhaiiiiiii....❤️❤️
ReplyDeleteGlad to see you satisfied...❤️
Delete