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
- A variable can have alphabets, underscore or digits.
- A variable name can start with the alphabet, and underscore only.
- It can not start with a digit.
- No whitespace is allow within the variable name.
- 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
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
Basic Data Type
- int
- char
- float
- double
Data Types | Memory Size | Range |
char | 1 byte | −128 to 127 |
short | 2 byte | −32,768 to 32,767 |
int | 2 byte | −32,768 to 32,767 |
short int | 2 byte | −32,768 to 32,767 |
long int | 4 byte | -2,147,483,648 to 2,147,483,647 |
float | 4 byte | |
double | 8 byte | |
long double | 10 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
0 Comments