C Tutorials
- What is C?
- History Of C?
- Feature of C?
- How to Install C?
- How to write c program?
- First c program
- Flow of C program
- printf() and scanf() in C
- C Program Structure
- Variables in C
- Data Types in C
- Keywords in C
- C Operators
- Comments in C
- Escape Sequence in C
- Escape Sequence in C
- Constants in C
- C - Storage Classes
- C - Decision Making
- Switch statement in C
- C Loops
- Loop Control Statements
- Type Casting in C
- functions in C
- call by value Or call by reference
- Recursion in C
- Storage Classes in C
- Array
- String
- Pointer
- Pointer And Array
- Pointer with function
- Structure
- Union
- File Handling
- Preprocessor Directives
Important Links
Type Casting in C
Type casting allows us to convert one data type into other. In C language, we use cast operator for type casting which is denoted by (type).
Without Type Casting:
int f= 9/4;
printf("f : %d\n", f );//Output: 2
With Type Casting:
float f=(float) 9/4;
printf("f : %f\n", f );//Output: 2.250000
Example :-
int main(){
float f= (float)9/4;
printf("f : %f\n", f );
return 0;
}
float f= (float)9/4;
printf("f : %f\n", f );
return 0;
}