> #programming , #computer-science > Write a C program in a file named data_type_operators.c that demonstrates the use of different data types and performs operations using arithmetic and relational operators.
Anonymous
Oct 14

Write a C program in a file named data_type_operators.c that demonstrates the use of different data types and performs operations using arithmetic and relational operators.

1 view
1 view

1 answer

Sort By
C
ChatGPT
Oct 14
#include

int main() {
// Integer data types
int a = 10, b = 5;
printf("Integer data types:\n");
printf("a + b = %d\n", a + b);
printf("a - b = %d\n", a - b);
printf("a * b = %d\n", a * b);
printf("a / b = %d\n", a / b);
printf("a %% b = %d\n", a % b);
printf("a > b is %d\n", a > b);
printf("a < b is %d\n", a < b);
printf("a == b is %d\n", a == b);

// Floating point data types
float c = 10.5, d = 3.5;
printf("\nFloating point data types:\n");
printf("c + d = %f\n", c + d);
printf("c - d = %f\n", c - d);
printf("c * d = %f\n", c * d);
printf("c / d = %f\n", c / d);
printf("c > d is %d\n", c > d);
printf("c < d is %d\n", c < d);
printf("c == d is %d\n", c == d);

// Character data types
char e = 'A', f = 'B';
printf("\nCharacter data types:\n");
printf("e + f = %d\n", e + f);
printf("e - f = %d\n", e - f);
printf("e > f is %d\n", e > f);
printf("e < f is %d\n", e < f);
printf("e == f is %d\n", e == f);

return 0;
}
1

Similar Questions

×
Anonymous





© 2024 - Quanswer