void main()
  int a, b, c;
  pritnf("Please enter first value:");
  //Accepting the first value from keyboard
  pritnf("Please enter second value:");
  //Accepting the second value from keyboard
  //Adding two numbers
  //Printing the output
Please enter first value: 10
Please enter second value: 20


  • Each and every C program execution starts with main function. The first statement in our main function declares three variables called a, b, c
  • 3 memory locations are created with the a, b, c variable declaration. a and b will hold the value entered at the run time and c holds the result of the addition
  • printf statemtn prints the information on the standard console device (i.e.; monitor)
  • scanf statement waits for user input from the standard input device (i.e.; keyboard) and when the value is entered, it will be pushed to the corresponding variable
  • + operator adds two operands and returns the result
  • = operator assigns the value to the variable