Variable Declaration in C With Example -

Consider the below points while variable declaration in C language

  • Uppercase and lowercase alphabets are taken differently. For example, the variables ‘SUM’ and ‘sum’ are pointing to different values.
  • No special characters other than underscore(_) are permitted.
  • Some C compilers will not accept more than 8 characters. So it is better to declare a variable with a few letters that make it easy to use.
  • All the variables used in the C program are declared with the appropriate data types before assigning a value to that variable. For eg:- int intNum = 3;
  • reserved words can not be used as variables.
#include <stdio.h> 
int main()
{
// Create variables
int intNum = 3; // Integer (whole number)
float floatNum = 3.99; // Floating point number
char letter = 'C'; // Character
// Print variables
printf("%d\n", intNum);
printf("%f\n", floatNum);
printf("%c\n", letter);
return 0;
}

--

--

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bipsmedium

Bipsmedium

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.