At primary stage C data types are divided into 3 categories : integer ,character and real. Let us explore these data types.
It’s simple to understand that integer data types in C are used to store a integer value .
The basic Syntax to declare them is shown below:-
Range:Range of an integer constant is depends upon the compiler.For 64bit compilers like gcc and visual studio it’s range is -2147483648 to +2147483647 and for 16bit compilers/emulators like turboC or turboC++ the range is -32768 to +32767.
Warning:If you want to print a Integer value greater than it’s max it shows min value of Integer and vice-versa.
// Double slash is use for comments
/* This format is use for multi line comments
and comments are not compiled by compiler
printf(“Hello from Buffercode.in”);
printf(“sorry the max value of x=%dn “,x); // n is use for new line
Hello from Buffercode.in
- To display output we use the it’s inbuilt functions like printf().
- It is compulsory to use #include<stdio.h> at the beginning of the program.
- General form of printf() function:
printf(“<format string”,list of variables);
- <format string> can contain:
%d for integer values
%f for real or floating type values
%c for character type values
Real or Floating point numbers:
Real constants are also known as floating point numbers. These are the numbers having decimal in it Ex 123.45
These can be written in fractional form as well as exponential form .Ex 123.45(fractional) & 1.2e-4
Range of real constants and variables is from -3.4e38 to 3.4e38
float x; //semicolon(“;”) is necessary after each statements
float x=123.45; //defining and declaring at same time
A character is a single alphabet,digit or a special single enclosed within a single inverted commas(‘a’).
It’s max length is 1 character.
char x=’A’ //declaration with defination
For now it’s enough to know about C data types , In later posts we revisited them to explore C data types.