sponsor

sponsor

Slider

Recent Tube

Business

Technology

Life & style

Games

Sports

Fashion

» » Type Casting

Type Casting में एक variable को दूसरे variable में convert किया जाता है |
For example अगर किसी variable को integer से float या float से integer में convert किया जाता है, तो उसे Type Casting कहते है |

int
float

Syntax for Type Casting

(data_type_name) expression

Source Code :
#include <stdio.h>

int main(){

int a, b;
float c;

    printf("Enter value of a : ");
    scanf("%d", &a);
    printf("Enter value of b : ");
    scanf("%d", &b);

   c = (float) a / b;
   printf("%f", c);

return 0;
}
Output :
Enter value of a : 15
Enter value of b : 6
2.500000

Float to Integer


char
int
Source Code :
#include <stdio.h>

int main(){

char c = 'a';

    printf("ASCII value of %c is %d", c, c);

return 0;
}
Output :
ASCII value of a is 97

«
Next
Newer Post
»
Previous
Older Post

No comments:

Leave a Reply