Program to add two numbers

C Programming Language Fundamentals of C Language (Article) Fundamentals of C Language (Program)

4267

Program:

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

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.


This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.