Tuesday, 2 July 2019

Datatypes and Variables in C

Datatypes and Variables in C







Welcome back friends, today we will continue with Datatypes and Variables.
Datatypes: we need to first identify the type of data to store the data in C program.C language provides four basic datatypes such as char,int,float and double.


DataType
Type of Data
Memory
Int
Integer Type
2 bytes
Char
Character Type
1 byte
Float
Floating Point Numbers
4 byte
Double
Floating Point Numbers with higher precision
8 byte

Variables:A variable is a dataname used for storing a data value.It also called as memory allocators which is used to allocate the memory for any data value in system.It can store single value at a time.A variable can be assigned different values at different times during the program execution.For example: marks,sum,add etc…

But there are some rules to declare variables :

1.A variable must begin with a character or an underscore(_) without any spaces.
2.The variable should not be a C keyword.
3.The variable should not be start with a digit.
4.We cannot use blank spaces and commas with in a variable name.

As we know we will have to declare the variable to store data.Before declaring variable name we will have to mention the type of data so that variable is able to store the data of the given type. For example: int num;

Lets take an example:


How to create variable in C


Here we written '%d',This is Format Specifier which is used to display integer value on the output screen in C language.

we will discuss different specifiers later in detail....

Variable Program in C

No comments:

Post a Comment

Recent Post

Python Project | Banking System | Project on Banking System using python

  PYTHON PROJECT Banking System import csv import pandas as pd import matplotlib.pyplot as plt import sys import datetime found=False def ne...