Professional Documents
Culture Documents
C Language (Day-02)
C Language (Day-02)
Gorakhpur Center
Ministry of Electronics & Information Technology (MeitY), Government of India
Identifier
• Identifier is the name of a variable that is made up from combination of
alphabets, digits and underscore.
Variable
• It is a data name which is used to store data and may change during
program execution. It is opposite to constant. Variable name is a name
http://www.nielit.gov.in/gorakhpur /GKP.NIELIT @GKP_NIELIT /NIELITIndia /school/NIELITIndia
Rules for Variables
First character should be letter or alphabet.
Keywords are not allowed to use as a variable name.
White space is not allowed.
C is case sensitive i.e. UPPER and lower case are significant.
Only underscore, special symbol is allowed between two characters.
2. Integer Constant :
It should not contain a decimal place.
It can be positive or negative.
Example: 1990, 194, -394
http://www.nielit.gov.in/gorakhpur /GKP.NIELIT @GKP_NIELIT /NIELITIndia /school/NIELITIndia
Constant in C Contd..
3. Character Constant :
It is a single alphabet or a digit or a special symbol enclosed in a single quote.
Maximum length of a character constant is 1.
Example: 'T', '9', '$'
4. String Constant :
It may contain letters, digits, special characters and blank space.
Example: “Hello friends"
Right Shift
Left Shift
z=y>>1
z=y<<1
print(z) Output
Output print(z)
z=y>>2 3 14
z=y<<2
print(z) 1 28
print(z) 56
z=y>>3 0
z=y<<3
print(z)
print(z)
NOTE:
For multiply given number by two, left shifted by one time, i.e., a<<1
For divide given number by two, right shifted by one time, i.e., a>>1
http://www.nielit.gov.in/gorakhpur /GKP.NIELIT @GKP_NIELIT /NIELITIndia /school/NIELITIndia
Example of Bitwise Operator
Example:
void main()
{
int x,y;
clrscr();
printf(“Enter value of x:”);
scanf(“%d”,&x);
y=x<<3;
printf(“Left shifted data=%d”,y);
printf(“Right shifted data=%d”,x>>3);
}
5. What is C Tokens?
A. The smallest individual units of c program
B. The basic element recognized by the compiler
C. The largest individual units of program
D. A & B Both Answer : D
6. What is Keywords?
A. Keywords have some predefine meanings and these meanings can be changed.
B. Keywords have some unknown meanings and these meanings cannot be changed.
C. Keywords have some predefine meanings and these meanings cannot be changed.
D. None of the above Answer : C
7. What is constant?
A. Constants have fixed values that do not change during the execution of a program
B. Constants have fixed values that change during the execution of a program
C. Constants have unknown values that may be change during the execution of a program
D. None of the above Answer : A
8. Which is the right way to declare constant in C?
A. int constant var =10; B. int const var = 10;
C. const int var = 10; D. B & C Both Answer : D
9. What will be the output of the following arithmetic expression ?
5+3*2%10-8*6
A. -37 B. -42
C. -32 D. -28 Ans: a