ankitweblogic logo
W e b t u t o r i a l s

C Tutorial

Programing Approach


Flow Chart

Define C

Define Programming

C - Syntax

Compiler vs Interpreter

C - Variables

C - Keywords

C - Data Types

C - Comments

Turbo C - Shortcut keys

C - Operators

Hierarchy of Operators

Ex: Arithmetic Operator

C - Formatting Output

Constant Variable

C - Escape Sequence

C - if , switch

Ex: If condition

Ex: Inc / Dec Operator

C - loops

Ex: Loops

C - Nesting Of loops

Ex: Nested Loops

Jumping Statements

C - Arrays 1D

C - Arrays 2D

C - Sorting


Character I/O Function

C - String Functions

Ex: Strings

Array of Strings

C - Math Functions

User-defined Function

Exercise Function

C - Types of Functions

Storage Class

C - Header Files

C - Preprocessor

C - Pointers

C - Structures

C - Typedef

C - File Handling

Ex: File Handling

Command Line Argument


Define C Variable

Variables are use to store values temporary entered by a user. Variables are the entity that may vary during program execution. Variable names are called identifiers.

Rules to declare a variable:

  1. The variable name can contains of any sequence of alphabets, numbers and underscore.
  2. Variable name can be Alpha-numeric e.g. no1.
  3. Special characters, blank space or comma are not allowed.
  4. A variable name can start with alphabet and underscore only. It can't start with a digit.
  5. Upper and lower case letters are distinguishable.
  6. A Keyword cannot be used to declare a variable name.

Some valid variable names:

int _a; //can start with underscore character.
float r1; //can contain number.
double circle_area; //can contain underscore character.

Some in-valid variable names:

int $a; //cannot start with special symbols like $.
float 1r; //invalid, cannot start with a number.
double circle area; //invalid, cannot contain space.

Note: In C, all variables must be declared before use with its data type.

Example 1: Program to explain variable declaration and assignment.


void main()
   int a, b, c; //variable declaration
   a=10; //variable assignment
   b=20; //variable assignment
   printf("\nSum = %d",c);
Sum = 30