Question : C program to perform basic arithmetic operations which are addition, subtraction, multiplication and division of two numbers. Numbers are assumed to be integers and will be entered by the user.
/*
C program to perform basic arithmetic operations which are addition, subtraction, multiplication and division of two numbers. Numbers are assumed to be integers and will be entered by the user.
Addition = First Number + Second Number
Subtraction = First Number - Second Number
Multiplication = First Number * Second Number
Division = First Number / (float) Second Number
Subtraction = First Number - Second Number
Multiplication = First Number * Second Number
Division = First Number / (float) Second Number
*/
#include <stdio.h>
int main()
{
int first, second, add, subtract, multiply;
float divide;
printf("Enter First integers\n");
scanf("%d ", &first);
{
int first, second, add, subtract, multiply;
float divide;
printf("Enter First integers\n");
scanf("%d ", &first);
printf("Enter Second integers\n");
scanf("%d",&second);
add = first + second;
subtract = first - second;
multiply = first * second;
divide = first / (float)second; /*typecasting*/
scanf("%d",&second);
add = first + second;
subtract = first - second;
multiply = first * second;
divide = first / (float)second; /*typecasting*/
printf("Sum = %d\n", add);
printf("Difference = %d\n", subtract);
printf("Multiplication = %d\n", multiply);
printf("Division = %.2f\n", divide);
return (0);
printf("Difference = %d\n", subtract);
printf("Multiplication = %d\n", multiply);
printf("Division = %.2f\n", divide);
return (0);
}
OUTPUT :
Enter First integers
7
Enter Second integers
3
Sum = 10
Difference = 4
Multiplication = 21
Division = 2.33
Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.
Please do comment and share.
Thank You.
Please do comment and share.
Thank You.
No comments:
Post a Comment