Introduction to c Programming

C is very basic programming language. Before starting learning this try following programs in your c compilers. 1) Print “Hello”



void main()





2) Addition of two numbers

void main()
int a,b,c;
printf("Enter 1st no.");
scanf("%d" ,&a);
printf("Enter 2nd no.");
scanf("%d" ,&b);
printf("The answer is : %d", c);

How to run the program
To compile press Alt+F9 To run press cntrl+F9 (if there are no errors)Lets see some of the Basic terminologies used in above 2 programs

What is printf and scanf ?

Printf function will print the text inside ” ” (double quotes). scanf will read the entered input by the user

What are data types ?

In above example i.e. addition of two numbers we have taken 3 variables a,b & c. all are of int type. int tells us that these are intergers. if we try to enter decimal values in the input it will give us error. so for that we have another datatype i.e. float using this we can use decimal values.e.g. float a,b;few more data types

Type     syntax     size(bytes)
Integer    int    2
Float     Float     4
Character     Char     1


What are format specifier ?
in the second program you have seen %d in scanf & printf statement. It is nothing but format specifier. It is used for integer. there are many format specifiers for e.g.

Data type Format specifiers
 int  %d
Char %c
Float %f


What is an expression ?
In the above program c=a+b it is called as expression. we can use such expressions in c

why ; (semicolon) ?
In C every statement ends with semicolon . it seperates one statement from another statement.

1. Write a program for sub straction of two numbers.
2. Write a program to find area of a rectangle.
3. Write a program to find area of circle.
4. write a program to calculate the speed when user enters time & distance using the formula speed=distance/time.


Subscribe to YouTube

Training on Selenium

Like us on facebook



Cooking with Amol