Part 1: C Programming Series

Computer is an advanced electronic device that performs certain computations as per the user requirements. It receives raw data as an INPUT from the users to process and generates desired result as OUTPUT .

The major four functions of a Computer System which ensures the proper functioning of processes are:

1. INPUT: The written computer Program receives raw data as an input from end users through input Devices such as keyword. In C programming, the programmers make use of getch() -to get a character and gets() – to get a String to read raw data from the keyboard. For Ex: to read two values of integer data type :

scanf("%d %d",& n1,& n2); // here scanf takes two integer inputs from the user using the appropriate syntax 

2. PROCESS: The raw data will be processed by Central Processing Unit or CPU, i.e. the programmer makes the use of operators and expressions to get the desired Result. For example: to find the sum i.e.; result in an addition of two numbers a1 and a2 we write:

 sum = a1 + a2; // the summation obtained will be stored in variable sum 

3. OUTPUT: The processed data or information can be displayed on the monitor screen. For this purpose, C programmer makes use of output functions like printf() – print function, putch() – to print a character and puts()-to print a string etc.For Ex: to display result on the monitor screen

printf("\n the addition of two integer numbers is %d",sum);

4. STORE: The input and output data can be stored in the computer’s secondary memory like hard disks for future use with a suitable file name. For this purpose, the C programmer makes the use of “FILE HANDLING” functions like

  • fopen() – to open a file,
  • fscanf()-to allow user to give input for a file,
  • fprintf() – to print something in the file as desired by the programmer,
  • fgetc()– to get a character from a file,
  • fputc() – to place a character in the file,
  • fgetw and fputw – to get and place a word from and into the file respectively .

Computer program: The set of instructions (statements or commands) given to the computer system to perform a specific task is defined as Computer Program.

For a better clarity, go through the following simple C program to display “Hello world” message on the screen:

A Simple C Program

void main()
   printf("Hello World!");

The above code is the easiest program in C Language possible. Here ,the user simply attempts to print the message “Hello World!”

C Program to Find Addition of Two Numbers:

void main()
   int n1,n2,sum;
   printf("enter the two numbers ");
   scanf("%d %d",&amp;n1,&amp;n2);
   printf("\n Addition is %d",sum);

enter the two numbers 
7 3
Addition is 10

The above code is to add to integer numbers i.e; n1 and n2 and store the result in the variable sum.Then, a printf statement is used to print the sum variable .

C Program to Find Addition, Substraction, Multiplication and Division of Two Unknown Whole Numbers :

void main()
   int n1,n2,sum,subs,mul,
   float div;
   printf("Enter the two numbers ");
   scanf("%d %d",&amp;n1,&amp;n2);
   sum = n1+n2;
   subs = n1-n2;
   mul = n1*n2;
   div = n1/n2;
   printf("the addition of two numbers is : %d ",sum);
   printf("the substraction of two numbers is : %d ",subs);
   printf("the multiplication of two numbers is : %d ",mul);
   printf("the division of two numbers is : %f ",div);

Enter the two numbers
4 2 
the addition of two numbers is : 6
the substraction of two numbers is : 2
the multiplication of two numbers is : 8
the division of two numbers is : 2.0

The above program various operations are performed and the respective results obtained are printed. The user gives two integer inputs and performs addition, substraction, multiplication storing the results in variables: sum, subs, mul and div respectively. The results are then printed in a sequence as seen above.

C Program to Find the Area and Circumference of a Circle

void main()
   float r,area,cir;
   printf("Enter Radius of circle: ");
   area=3.142 *r*r;
   printf("Area of the circle : %f",area);
   printf("Circumference of the circle : %f",cir);

Enter Radius of Circle:
Area of the circle : 50.272
Circumference of the circle : 25.136

In this program, the user is requested to enter a radius and using the entered radius, the area and circumference of the circle are calculated using the mathematical formula. The respective results are then printed as shown above .

C Program to Convert Temperature Reading from Celsius to Fahrenheit :

void main()
   float f,c;
   printf("\n Enter temperature reading in Celsius: ");
   printf("\n Temperature reading in Fahrenheit : %f",f);

Enter temperature reading in Celsius:
Temperature reading in Fahrenheit : 41

/*To Remember : from Fahrenheit to Celsius conversion : c= 5/9 * (f-32)
               from celsius to Fahrenheit conversion : f=9/5 * c + 32 */

In this C program, user provides a temperature in Celsius and that temperature is converted to Fahrenheit. After the conversion, the Fahrenheit temperature is printed . You can also convert the Fahrenheit temperature to Celsius in the similar manner using the appropriate conversion formula .
Do you like Divya Khyani's articles? Follow on social!
Comments to: Introduction to C Programming

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

Download VTU Connect

Get it on Google Play

Latest Articles

VTU Updates

Submission of online application forms for I sem BE/B.Tech Examinations to be held during April 2021 by the eligible students is scheduled as given below: Event Last Date Communication of passwords to students from colleges 05/04/2021 Filing examination application forms by the students / colleges 05/04/2021 – 15/04/2021 Approval of application forms filed by the […]
Last Updated: 01/04/2021 Conduct of III Sem BE/B.Tech Practical Examinations Event Dates Uploading the batch list through web interface by departments and approval of batches by principals of respective institutes 03/04/2021 – 05/04/2021 Allocation of examiners by principals of respective institutes 6/04/2021 – 07/04/2021 Schedule of examinations 8/4/2021 – 17/4/2021 *(Excluding 11,13,14th of April 2021 […]
LAST UPDATE 13/03/2021 Revised Academic Calendar for I, III, V, and VII semesters of B.E./B.Tech./B.Plan and IXsemester of B.Arch., III and V semester of MCA and III semesters of MBA, M.Tech., M.Arch., for the Academic Year 2020-21 is announced by VTU. I Semester BE/B.Tech/B.Arch/ B.Plan[Updated 13/03/2021] III Semester Regular / Lateral Entry BE/B.Tech [Updated 01/03/2021] […]


VTU has released circular specifying the question paper pattern and instructions for August/September 2020 examinations. 1. For Regular Students: Students of Terminal Semesters of U.G and P.G programs have to answer any five full questions, irrespective of modules. 2. For Eligible Arrear Students: The question paper pattern remains unchanged as per respective scheme. 3. All […]

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.



Welcome to VTU Connect

Register to VTU Connect now for instant updates on new articles and news
Join VTU Connect
Registration is closed.
%d bloggers like this: