Skip to content

Instantly share code, notes, and snippets.

@sutirthaC97
Forked from anonymous/datatypes-example.c
Last active April 9, 2017 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sutirthaC97/4bde74331a20b57d11c7e62f066b37ae to your computer and use it in GitHub Desktop.
Save sutirthaC97/4bde74331a20b57d11c7e62f066b37ae to your computer and use it in GitHub Desktop.
An example C program demonstrating different data types, their variables and their naming conventions.
/*An example C program to demonstrate different data types.*/
#include <stdio.h>
int main()
{
int meaningOfLife = 42;
float a_random_float = 56.9;
double pi = 3.141;
char c = 'c';
printf("\nThe integer meaningOfLife holds the value: %d and it's size is: %d", meaningOfLife, sizeof(meaningOfLife));
printf("\nThe float a_random_float holds the value: %f and it's size is: %d", a_random_float, sizeof(a_random_float));
printf("\nThe double pi holds the value: %lf and it's size is: %d", pi, sizeof(pi));
printf("\nThe character c holds the value: %c and it's size is: %d", c, sizeof(c));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment