C language Tutorial with programming approach for beginners and professionals, helps you to understand the C language tutorial easily. Our C tutorial explains each or every topic with example.

The C programing language is a procedural and general- purpose language that rovides low-level access to System memory is knows as C programming language.

Variable in C

A variable is a name of the memory location. It is use to store data. Its value can be change, and it can be reused many time is knows as Variable in C.

Syntax

  • type variable_list;  

Rules for defining variables

  1. A variable can have alphabets, underscore or digits.
  2. A variable name can start with the alphabet, and underscore only.
  3. It can not start with a digit.
  4. No whitespace is allow within the variable name.
  5. A variable name must not be any reserve word or keyword.

Types of Variables in C

There are some important types of variables in c

  • local variable
    • Declare inside the function
  • global variable
    • Declare outside the function
  • static variable
    • Declare with the static keyword
  • automatic variable
    • Declare inside the block, are automatic variables by default
  • external variable

Simple example of Variables Declaration in C

Input value

#include <stdio.h>
extern int a, b;
extern int c;
extern float f;

int main () {

   int a, b;
   int c;
   float f;

   a = 45;
   b = 25;
  
   c = a + b;
   printf("value of c : %d \n", c);

   f = 72.0/3.0;
   printf("value of f : %f \n", f);
 
   return 0;
}

Output value

Output value

DATATYPES

A data type specifies the type of data that a variable can store just like as integer, floating, character, etc. is knows as DataTypes in C programming language.

TYPES OF DATATYPES

Datatypes of C programming Language
DATATYPES

Basic Data Type

  • int
  • char
  • float
  • double
Data TypesMemory Size Range
char1 byte−128 to 127
short2 byte−32,768 to 32,767
int2 byte−32,768 to 32,767
short int2 byte−32,768 to 32,767
long int4 byte-2,147,483,648 to 2,147,483,647
float4 byte
double8 byte
long double10 byte

Derived Data Type

  • array
  • pointer
  • structure
  • union

Enumeration Data Type

  • enum

VOID

  • Void

If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.

To know more about C Programming language please Wikipedia click here .

Stay Connected Stay Safe, Thank you


Basic Engineer

Hey Readers! We have more than fifteen years of experience in Software Development, IoT, Telecom, Banking, Finance and Embedded domain. Currently we are actively working on Data Science, ML and AI with multiple market leaders worldwide. Happy Reading. Cheers!

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *