Home / Programs / Program to add two numbers
🚀 Programming Example

Program to add two numbers

👁 4,334 Views
💻 Practical Program
📘 Step Learning
In this program we will add two floating point value (30.75 + 75.35). In case of floating point addition it will give decimal point value as a result.

💻 Program Code

/* 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);  
}   
                        

🖥 Program Output

100

106.10
Press any key to continue . . .
                            

📘 Explanation

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.

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

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.

🔥 Practice suggestion

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.