/* 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 understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.