C Subtract Programming for beginners
In this example of C tutorial, we will take two integers from the user using scanf() function and print the subtracted value in the console/screen.
Write a C program to print the subtracted value of two numbers.
Program:
================================
================================
Output:
================================
Enter the first and second number
50 45
The sum is 5
================================
Explanation of the program:
# : If any line start with #, it is a pre-process only that
line. Special symbol (#) to indicate the pre-processor directive.
include : pre-processor directive. I include important file
in the C program.
stdio.h : This file contains functions such as printf() and
scanf() to print in the screen and taking input from the user.
main() : The C program execution starts from this line. The
main() function is called by the operating system (O/S).
int : It is an Integer data type.
number1/ number2/sub : They are the variable to store
integer data type. Just like the bucket is to store water, this variable is to
store integer numbers.
scanf() : It is a function defined in the stdio.h header
file, to take the date from the user.
%d : It is the format specifier for the Integer data type.
& : Address of any variable in the memory.
printf() : It is a function defined in the stdio.h header
file, to print or send output to the screen/consol.
return 0 : This statement is to Exit the program. It tells the operating system (O/S) that the program has run successfully, as 0 means success. In place of 0 we can use any number like 1, 2,… but the general convention is to write 0.
0 Comments