Skip to main content

Constants and Variables in C


Constants in C: Constants are the terms that can't be changed during the execution of a program.

Examples: Integer Constants: 0, 1, 2, 3, 4, 5, 6, 7 . . . . . . .
Floating Constants: 0.0, 0.1, 0.2, 0.3, -0.4, 0.5, 5.1546, 2.5465, -1.02545 . . . . . . . 
Character  Constants:  Character  constants  are  the  constant  which  use  single  quotation  around 
characters. For example: 'a', 'l', 'm', 'F' etc.

Variables in C: Variables are memory location in computer's memory to store data. To indicate the memory location, each variable should be given a unique name called identifier. Variable names are just  the  symbolic  representation  of  a  memory  location.  Examples  of  variable  name:  ABC,  var_no, var_123, Var123, Count etc.

Basic Data Types in C: 

Char: a single byte that can hold a character (‘a’, ’b’, ’c’, ’d’, ’e’ . . . . . . . ) 
Int: An Integer can hold 2 or 4 byte integers (0, 1, 2, 3, 4, 5, 6, 7 . . . . . . .)
Float: A float can hold 4 byte floating points (0.0, 0.1,0.2, 0.3, -0.4,0.5,5.1546, 2.5465, -1.02545 . . .)
Double: Double is same as float just the difference is it can hold up to 8 byte (0.0, 0.1, 0.2, 0.3, -0.4, 
0.5, 5.1546, 2.5465, -1.02545 . . . . . . .)

Rules for writing variable name in C:

The first letter of a variable should be a letter, Variable name can be made up of both uppercase and lowercase letters, digits and underscore (_) only.

Declaration of Variable
#include <stdio.h>
void main(){
int a1, a2;
int a_1;
void main ( ){ 
char b_1;
double db;
void main(){
float a_1, b2, b3, b4;
char jvh;
a1, a2 and a_1 are declared as integer now they can store integers.
b_1 and db are declared as char and do uble respectively now b_1 can store characters(fonts) and db can store fractioned numbers.
Here a_1, b2, b3, b4 can store floating points and jvh can store charac

Initialization of Variable
void main ( ){
float b1 ;
b1 = 2.302;
double a;
a = 7.202;
void main ( ){ 
char b_1 ;
b_1 = ‘r’;
int a;
a = 7;
#include <stdio.h>
void main(){
int a1 = 5;
int b1;
b1 = 5;
B1 and a are declared and initialized.
Here b_1 is stores / initialize r
And a store’s 7 ..
a1 is initialized during declaration and b1 firstly initialize then declare on second line.


  1. Injection molding is essentially the most generally used manufacturing process for the fabrication of plastic parts. A extensive variety of products are manufactured using injection molding, which range tremendously in their measurement, complexity, and application. The injection molding process requires utilization of} an injection molding machine, uncooked plastic materials, and a mould. The plastic is melted within the injection molding machine and then injected into the mould, where it cools and solidifies into the ultimate half. The steps on this process are described in greater detail within the subsequent section. The trade expanded quickly within the Nineteen Forties outcome of|as a end result of} World War II created a huge demand for inexpensive, Mittens mass-produced products.


Post a Comment

Popular posts from this blog

Comments in C

  Comment is the code which is not executable means compiler will not compile the comments and that’s why comments are not visible on output screen. Two types of Commenting: Type 1:  double slash ‘ // ’ method the whole statement after double slash is not executed by compiler Example: try to run below code its output will be blank screen #include <stdio.h> void main(){ // printf (“Hello World!”); } #include<stdio.h> void main ( ){ //Comments // Comment printf (“Hello World!”);//abc } #include<stdio.h> //Comments void main(){ //Comments printf(“Hello World”); } o/p:  blank screen O/p:  Hello World! O/p:  Hello World In this way you can give multiple comments anywhere in the program but double slash is used to  comment only single line for commenting multiple lines use type 2.  Type 2:  For multiline commenting or for commenting a whole paragraph from the program we have  to add /* at the start of comment and */ at the end of comment as shown in examples: #include <s

New trends and advantages of C language.

1. You can program the ROBOTS and  Automatic Running Machines  using C language. click here for more information.  2. For building more advanced  software or  Games you need to  learn more advanced languages like  Visual  Basic,  .NET, JAVA, ANDROID programming which is based on C.  3. To build a website you need only HTML and you can make your own website but for making it more advance you need to learn more web designing languages like CSS, JavaScript, Ajax, PHP and this all languages are very easy to learn if you have some basic knowledge about C. 4. After learning C you will be able to make your own software like Calculator, Games, Embedded Softwares, Compilers.