Variable & Data Types – Let us C https://c.praveshagrawal.com Example C Programs Sat, 02 Dec 2023 11:29:22 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 Type Casting https://c.praveshagrawal.com/2023/12/02/type-casting/ https://c.praveshagrawal.com/2023/12/02/type-casting/#respond Sat, 02 Dec 2023 11:29:22 +0000 https://c.praveshagrawal.com/?p=136 #include <stdio.h> int main() { // Type casting double doubleVar = 3.14; int intVar; intVar = (int)doubleVar; printf("Double: %lf\n", doubleVar); printf("Int: %d\n", intVar); return 0; } ]]> https://c.praveshagrawal.com/2023/12/02/type-casting/feed/ 0 Size of Data Types https://c.praveshagrawal.com/2023/12/02/size-of-data-types/ https://c.praveshagrawal.com/2023/12/02/size-of-data-types/#respond Sat, 02 Dec 2023 11:29:08 +0000 https://c.praveshagrawal.com/?p=137 #include <stdio.h> int main() { // Size of data types printf("Size of int: %lu bytes\n", sizeof(int)); printf("Size of float: %lu bytes\n", sizeof(float)); printf("Size of char: %lu bytes\n", sizeof(char)); return 0; } ]]> https://c.praveshagrawal.com/2023/12/02/size-of-data-types/feed/ 0 Constants and Enums https://c.praveshagrawal.com/2023/12/02/constants-and-enums/ https://c.praveshagrawal.com/2023/12/02/constants-and-enums/#respond Sat, 02 Dec 2023 11:28:54 +0000 https://c.praveshagrawal.com/?p=138 #include <stdio.h> // Enum for days of the week enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; int main() { // Constants and enums const double PI = 3.14159; enum Days today = Wednesday; printf("Value of PI: %f\n", PI); printf("Today is day number: %d\n", today); return 0; } ]]> https://c.praveshagrawal.com/2023/12/02/constants-and-enums/feed/ 0 User Input and Type Conversion https://c.praveshagrawal.com/2023/12/02/user-input-and-type-conversion/ https://c.praveshagrawal.com/2023/12/02/user-input-and-type-conversion/#respond Sat, 02 Dec 2023 11:28:40 +0000 https://c.praveshagrawal.com/?p=139 #include <stdio.h> int main() { // User input and type conversion int num1, num2; float result; printf("Enter two integers: "); scanf("%d %d", &num1, &num2); result = (float)num1 / num2; printf("Result of division: %f\n", result); return 0; } ]]> https://c.praveshagrawal.com/2023/12/02/user-input-and-type-conversion/feed/ 0 Basic Data Types https://c.praveshagrawal.com/2023/12/01/basic-data-types/ https://c.praveshagrawal.com/2023/12/01/basic-data-types/#respond Fri, 01 Dec 2023 14:06:25 +0000 https://c.praveshagrawal.com/?p=30 #include <stdio.h> int main() { // Basic data types int integerVar = 42; float floatVar = 3.14; char charVar = 'A'; printf("Integer: %d\n", integerVar); printf("Float: %f\n", floatVar); printf("Character: %c\n", charVar); return 0; } ]]> https://c.praveshagrawal.com/2023/12/01/basic-data-types/feed/ 0