Professional Documents
Culture Documents
INTEGER
FORMAT
NO DATATYPE RANGE BYTES
SPECIFIER
1 int -32768 TO +32767 2 %d
2 short signed int -32768 TO +32767 2 %d
3 short int -32768 TO +32767 2 %d
4 signed int -32768 TO +32767 2 %d
5 unsigned int 0 TO 65535 2 %u
6 short.unsigned int 0 TO 65535 2 %u
Primary Data Type is integer (int) whose range is -32768 To +32767 and
memory storage capacity is 2 bytes and for accessing and storage purpose %d
is used as a format specifier.
With int data type short signed keywords are used, short and signed integer is
the same as int , but unsigned int provided range 0 To 65535 whose format
specifier is %u and for printing address of a RAM unsigned int is used .
With a signed and unsigned keyword short keyword is also used but it will not
affect over a range.
DATA FORMAT
NO RANGE BYTES
TYPES SPECIFIER
7 long int -2147483648 To+2147483647 4 %ld
long signed
8 -2147483648 To +2147483648 4 %ld
int
long
9 0 to 4294967295 4 %lu
unsigned int
Long is keyword it provides double range with respect to int datatype .
Storage capacity becomes also twice with respect to int datatype (4 byte).
Prepared by Mr. Pankaj M. Zalera 1
Programing In C [SMT. V.B. NANDOLA COMPUTER SCIECNE COLLEGE, BHACHA]
DATA FORMAT
NO RANGE BYTES
TYPES SPECIFIER
1 float -3.4 e 38 to +3.4 e 38 4 %f
2 double -1.7 e 308 To +1.7 e 308 8 %lf
3 long double -1.7 e 4932 to +1.7 e 4932 10 %Lf
CHARACTER
FORMAT
NO DATA TYPES RANGE BYTE
SPECIFIER
1 char -128 to +127 1 %c
2 signed char -128 to +127 1 %c
3 unsigned char 0 to 255 1 %c
Character and signed character both declaration are same whose ASCII range
is -128 to +127 and unsigned character supports 0 to 255 ASCII range.
Memory storage capacity is 1 byte for a single character and format specifier
is %c with the help of char keyword and declaring fix size string can be scan.
e.g. char s[10];
String can be declared with char keyword and pointer *.
e.g. char *s;
1. Arithmetic.
2. Relational
3. Logical.
4. Assignment
5. Increment & Decrement.
6. Conditional.
7. Bitwise.
8. Special
1. Arithmetic Operator:
‘C’ provides all basic arithmetic operators. The operators +,-,* and / all work
in the same way as they do in other languages.
These operators can operate on any datatype allowed in ‘C’.
The modulor division produces the remainder of an integer division.
‘C’ does not have any operator for exponentiation.
There are five types of an arithmetic operation as given below:
3. Logical Operators:-
In addition to relational operators , C has following three logical operators :
NO. OPERATOR MEANING
1 && Logical AND
2 || Logical OR
3 ! Logical NOT
The logical operators && and || are used when we want to test more than one
condition and make decisions.
Some examples of the usage of logical expressions are:
1. if(age>55 && salary<1000)
2. if(number < 100 || number > 0)
3. if(year % 4 !=1)
NOT operator to test only one condition and make decision
4. Assignment Operators:
Assignment operators are used to assign the result of an expression to a
variable. We have seen the usual assignment operator “=”.
In addition, C has a set of short hand assignment operators.
Unary Operators
1. Prefix Operator :
2. Postfix Operator :
6. Conditional Operator :
Syntax:
“ If Expression1 is the true (That is , if its value is non-zero), then the value
returned will be.
Or
For example:-
7. Bitwise operators:
A=10 1010
B=11 1011
A&B 1010
8. Special Operators:
A. sizeof():
Return the size , in bytes of the given expression or type
Syntax:-
1. sizeof<Expression>
2. sizeof(<type>)
For example:
1. a=sizeof(int);
Output=2
2. b=sizeof(double);
Output=8
printf(“Enter Roll_no,Name,Per”);
scanf(“%d%s%f”,&r1.roll_no,&r1.name,&r1.per);
Prepared by Mr. Pankaj M. Zalera 9
Programing In C [SMT. V.B. NANDOLA COMPUTER SCIECNE COLLEGE, BHACHA]
scanf(“%d%s%f”,&r2->roll_no,&r2->name,&r2->per);
printf(“%d%s%f”,r1.roll_no,r1.name,r1.per);
printf(“%d%s%f”,r2->roll_no,r2->name,r2->per);
getch();
}
C. Comma operator:
The comma operator is used for separates the element of a function
argument/variable,list
Syntax:
exp1,exp2,…..expN;
For example:
f=(a=5,a+10,a+20);
Output: f=35
for(a=5,a=10,a=20;……;…….)
Result in the left-to-right evaluation of each a, thus a is contain different
values in step by step.
Q.3. write a note on following:
1. printf():
The printf() function is used to print out a message either on screen or on
paper.
Syntax:
printf(“<control string>”,var1,var2);
-Or-
printf(“<format string>”,<list of variables>);
Code Meaning
%d Prints a decimal integer
%c Prints a single character
%f Prints a floating point value
%u Prints a unsigned decimal integer
%lu Prints a long unsigned decimal integer
%ld Prints a long decimal integer
%lf Prints a double floating point value
%s Prints a string
Code Meaning
%d Reads a decimal integer
%c Reads a single character
%f Reads a floating point value
%u Reads a unsigned decimal integer
%ld Reads a long decimal integer
%lf Reads a double floating point value
%s Reads a string
%lu Reads a long unsigned decimal integer
3. clrscr ():
Used cleans text mode window
Declaration:-
clrscr();
Remarks:
clrscr() clears the current text window and places the cursor in
the window corner (at postion1,1).
Return value: none.
4. getch() :
getch() gets a character from console but does not echo to the screen
Declaration:-
getch();
Remarks:
getch() reads a single character directly from the keyboard, without echoing
to the screen .so this function return the character reads from the keyboard.
The fact that if the variable is not initialized, the auto storage class
contains a garbage value.
For example :
void main ()
{
register int i;
printf(“\n value of I %d “,i);
getch();
}
Output: 852
A value stored in a CPU register can always be accessed faster than the one
which in stored in a memory.
Therefore, if a variable is used at many places in a program it is better to
declared its storage class as register.
CPU register size is allowed 8 or 16 bits, so with register keyword
float,long,double can’t be use.
\” Double quotes