Lesson 2 : First C Program
Now Friends, that you are well equipped with the knowledge of keywords and identifiers, let us write a simple program to calculate the sum of two numbers entered by user. #include<stdio.h> void main() { int a,b,sum; printf("Enter two numbers"); scanf("%d %d " ,&a ,&b); sum=a+b; printf("Sum = %d "); } this program will have a output like this Enter two numbers 10 20 Sum = 30 Here in this program you can see few things, let us look at them line by line. 1. The first line contains "#include<stdio.h>" this is known as preprocessor. It says the compiler to include library file "stdio.h". ".h" represents a header file. This file contains the details for functions like printf, scanf and other input-output functions. 2. The 2nd line have void main() this is where our compiler starts reading the program. Every C program must contain one and only one main() function because this is were the compiler starts readi...