C Program : Type Casting Example

 #include <stdio.h>

int main() { int integerVar = 10; float floatVar = 3.14; double doubleVar; doubleVar = (double)integerVar; // Type cast integer to double printf("After type casting:\n"); printf("integerVar as a double: %.2lf\n", doubleVar); doubleVar = (double)floatVar; // Type cast float to double printf("floatVar as a double: %.2lf\n", doubleVar); int result; result = (int)(floatVar + 0.5); // Type cast and round a float to an integer printf("Rounded result: %d\n", result); return 0; }

Comments

Popular posts from this blog

Video Formats

Where video editing is used

File saving and folder management