/* Programm ADDITION */
/* Written by Rumman */
#include"stdio.h"
void main()
{
int number;
float amount;
number = 100;
amount = 30.75 + 75.35;
printf("%d\n \n",number);
printf("%5.2f \n",amount);
}
100
106.10
Press any key to continue . . .
This Program is a example of 'Addition of Two Numbers'
Here 'number' is a 'int' type variable, which can contain integer number and 'amount' is 'float' type variable, which can contain floating numbers.
number=100; defines that 100 is assigned into 'number' variable.
amount = 30.75 + 75.35; defines that addition of 30.75 and 75.35 assigned into 'amount' variable.
printf("%d",number); , It is a print statement. Here we using predefined 'printf' function to print the value of 'number'. '%d' means "print an integer" and '%f' means "print an floating number". Here '%d' and '%f' are "format specifier", which identify the output of 'printf' function.
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.