0% found this document useful (0 votes)
5 views2 pages

Basic C Programs for Arithmetic Operations

it is basic programs of c

Uploaded by

ujjwaldiwan411
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Basic C Programs for Arithmetic Operations

it is basic programs of c

Uploaded by

ujjwaldiwan411
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic C Programs: Addition, Subtraction,

Multiplication, Division

Addition
#include <stdio.h>

int main() {
int number1, number2, sum;

printf("Enter two numbers:\n");


scanf("%d %d", &number1, &number2);

sum = number1 + number2;

printf("%d + %d = %d\n", number1, number2, sum);

return 0;
}

Subtraction
#include <stdio.h>

int main() {
int number1, number2, difference;

printf("Enter two numbers:\n");


scanf("%d %d", &number1, &number2);

difference = number1 - number2;

printf("%d - %d = %d\n", number1, number2, difference);

return 0;
}

Multiplication
#include <stdio.h>

int main() {
int number1, number2, product;

printf("Enter two numbers:\n");


scanf("%d %d", &number1, &number2);

product = number1 * number2;

printf("%d * %d = %d\n", number1, number2, product);

return 0;
}

Division (Integer)
#include <stdio.h>

int main() {
int number1, number2, quotient;
printf("Enter two numbers:\n");
scanf("%d %d", &number1, &number2);

quotient = number1 / number2;

printf("%d / %d = %d\n", number1, number2, quotient);

return 0;
}

Division (Decimal)
#include <stdio.h>

int main() {
float number1, number2, result;

printf("Enter two numbers:\n");


scanf("%f %f", &number1, &number2);

result = number1 / number2;

printf("%.2f / %.2f = %.2f\n", number1, number2, result);

return 0;
}

You might also like