C Tutorial

Define C

Define Programming

Programming Approach

First C Program

TurboC Shortcut keys

Compiler vs Interpreter

C Variable

C Keywords

C Data Types

C Comments

C Operators

Hierarchy of Operators

Ex: Arithmetic Operator

C Formatting Output

C Escape Sequence

C if statement

Ex: If statement

C Switch statement

Ex: Switch

Increment / Decrement

C Loops

Ex: Loops

C Nesting Of Loops

Ex: Nested Loops

C Jumping Statements

C Exit(), Gotoxy()

C Arrays 1D

Ex: Arrays 1D

C Arrays 2D

Ex: Arrays 2D

C Sorting


Character I/O Function

Ex: Character

C String Functions

Ex: Strings

Array of Strings

C Math Functions

User-defined Function

Exercise Function

Local, Reference variable

Function Calling types

Array Passing Function

Recursion Function

Ex: Recursion Function

Constant Variable

Storage Class

C Header Files

C Preprocessor

C Pointers

Pointer to Pointer

C Structures

Exercise Structure

C Typedef

C Enumeration

C File Handling

Ex: File Handling

Command Line Argument



Page Stats

Visitor: 573

Constant Variable

Constant variables are those variables whose value cannot be changed during the execution of a program. Constant variable can be declared as local and global variable. Constant variable is declared with the keyword const.

Constant Variable Rule: Value of constant variable is assigned at the time of declaration only.

const int i = 5;
const float f = 5.5;
const char ch = 'a';
const a = 5; //can be declare as without data type.

Note: If data type is omit, in that case default data type is assigned that is int.

Example 1: Constant Variable declaration.

void main()
    const int a=10;
    printf("Value of a = %d\n",a);
    //a=20;//error, value of constant variable cannot be changed
Value of a = 10