#include <stdio.h>
int main()
{
// Declaring the variables
int n;
double n2,res;
// Initialize the variables by accepting values
printf("\nEnter any integer number:\n");
scanf("%d",&n);
printf("\nEnter any double number:\n");
scanf("%lf",&n2);
// Perform various arithmetic operations
res=n+n2;
printf("\nAddition:%d+%lf=%lf", n,n2,res);
res=n2-n;
printf("\nSubstraction:%d-%lf=%lf", n2,n,res);
res=n*n2;
printf("\nMultiplication:%d*%lf=%lf", n,n2,res);
res=n2/n;
printf("\nDivision:%d/%lf=%lf", n2,n1,res);
return 0;
}
Output:
Enter any integer number:
32
Enter any double number:
30.40
Addition: 30+30.40=60.40
Substraction: 30.40-30=0.40
Multiplication:30*30.40=912.00
Division:30.40/30=1.01333
Explanation:
The program begins by including the required stdio.h header file.
The main function declares two variables n and n2 to store integers and doubles entered by the user.
The user is prompted to enter an any integer number, which is then stored in the variable n using scanf.
Similarly, the user is prompted to enter a double number, which is stored in the variable n2 using scanf.
The program then performs arithmetic operations on the two numbers (addition res=n+n2, subtraction res=n2-n,
multiplication res=n*n2, division res=n2/n;) and the results shown using printf.Finally, the program terminates by returning 0; statement
1.Write a program in C to find area of circle using single-line comments.
2.Write a C program to find addition of two numbers with multi-line comments to write down the purpose of every steps.
3.Write a program in C that describe a complex mathematical formula with nested comments.
4.Write a C program to demonstrate the declaration and initialization of variables of different data types.
5.write a program code in c to swap a values of the two variable without using a third variable.
6.Write a program in c to find area of rectangle by accepting variable value length and width.
7.Write a program that accepts user input for employee name and salary, and then display them using those variables.
8.Write a program in C to demonstrate and decide the size of int, float, char, and double data types.
9.Write a program in C to convert temperature from Celsius to Fahrenheit using proper data types.
11.Write a program in C that accepts any two numbers from user and calculate addition, multiplication, subtraction and division (+, *,-, /) and show the result.
12.Write a program in c input user name, age And display it.
13.Write a program in C that asks the user to enter the marks obtained in three subjects. Read the marks using scan. Calculate the average marks and display the student details.
Other Topic:-->>Dynamic memory FAQ. || Operators Assignments in C.