type casting

 // typecasting syntax

// (type) value
#include <stdio.h>
int main()
{
    float a=10;
    float b=(float) 54/5; //here int & int will give int so we have to convert it to float for float no
    printf("%d\n",(int) a); // here i changed the type of the value a
    printf("%f",b);
    return 0;
}

Comments

Popular posts from this blog

Tokens in C

Steps taken by a compiler to execute a C program

Variables and Data Types in C