Title here
Summary here
C has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
#include <stdio.h>
#include <stdbool.h>
int main() {
// Strings in C are character arrays
// We can't directly add strings with +, so we use puts() to print them
printf("C");
printf("lang\n");
// Integers and floats
printf("1+1 = %d\n", 1 + 1);
printf("7.0/3.0 = %f\n", 7.0 / 3.0);
// Booleans in C are represented by integers
// 0 is false, any non-zero value is true
printf("%d\n", 1 && 0); // Equivalent to true && false
printf("%d\n", 1 || 0); // Equivalent to true || false
printf("%d\n", !1); // Equivalent to !true
return 0;
}To compile and run this C program:
$ gcc values.c -o values
$ ./values
Clang
1+1 = 2
7.0/3.0 = 2.333333
0
1
0In this C version:
printf instead of fmt.Println for output.+. Instead, we print them separately.<stdbool.h> for boolean operations.%d format specifier is used for integers, and %f for floats in printf.main function typically returns an integer, so we include return 0; at the end.This example demonstrates basic value types and operations in C, including string output, integer and float arithmetic, and logical operations.