Explanation of modifiers in
c programming language by examples and questions
Rules for using modifier in c
Rule 1: We cannot use
two modifiers of same groups in any particular data type of c.
For example,
following declaration of c are illegal:
short long int i;
static auto char c;
signed unsigned int array[5];
pascal cdecl display();
Following are
valid declaration of c:
const volatile float f;
signed static long volatile int i;
Question: Is following declaration is valid in c?
1. intnear * far * huge *p;
2. char const * const *c;
3. short short int i;
4. const const int i;
Rule 2: We can write
modifier either before the data type or after the data type. For example, both
of following declaration is correct:
unsigned char c;
char unsigned c;
Rule 3: Order of
modifier including data type doesn’t affect the meaning of declaration. For
example all of the following have same meaning:
int const short extern i;
int extern const short i;
int short extern const i;
const int short extern i;
extern short const int i;
Rule 4: There is one
exception in rule 3. POINTER, FUNCTION and INTERRUPT modifier must be written
after the data type. For example, in the following declaration:
unsigned const char far *c;
char unsigned const *c;
char far unsigned const *c;
const char far unsigned *c;
far char const unsigned *c;
const unsigned far char *c;
First four
declarations are valid as well as equivalent. But last two declarations are
invalid.
List of data types
Primitive data types in c
Modifiers of data types in c
List of modifiers in c
Default modifiers of data types in c
Default data of modifiers in c
Rules of using modifiers in c
Possibles modifiers of given data types in c
Size modifier in c
Size of data types in c
Sign modifier in c
Range of data types in c
Easy way to remember limit of data types in c
Const modifiers in c
Pointers modifier in c
Function modifier in c
Interrupt modifier in c
Volatile modifier in c
Fundamental data types in c
Memory representation of char in c
Memory representation of signed char in c
Memory representation of int in c
Memory representation of signed int in c
Memory representation of double in c
6 comments:
Please do post answer to questions as well. This will help in case of doubts. So,plz ans to these ques??
wat dout?
#include
const enum Alpha{
X,
Y=5,
Z
}p=10;
int main(){
enum Alpha a,b;
a= X;
b= Z;
printf("%d",a+b-p);
return 0;
}
Choose all that apply:
(A) -4
(B) -5
(C) 10
(D) 11
(E) Error: Cannot modify constant object
sir there is problem in above question answer of this question will be 1 instead of -4
because value of z will be 6 so that
a=5
b=6
a+b-p=5+6-10=1
so that please correct it sir
Question: Is following declaration is valid in c?
1. int near * far * huge *p;
2. char const * const *c;
3. short short int i;
4. const const int i;
ans : no
because all 4 options haveing same group of modifiers
A
Post a Comment