Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

Commit ca8538b

Browse files
Programs
1 parent 1e7dc90 commit ca8538b

27 files changed

+264
-6
lines changed

Arithmetic Problems/addition.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Add two numbers taking input from the user.
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int num1, num2, sum;
7+
printf("Enter the first number: \n");
8+
scanf("%d", &num1);
9+
10+
printf("Enter the second number: \n");
11+
scanf("%d", &num2);
12+
13+
sum = num1 + num2;
14+
15+
printf("Sum of the two numbers: %d \n", sum);
16+
17+
return 0;
18+
}

Arithmetic Problems/addition.exe

383 KB
Binary file not shown.

Arithmetic Problems/division.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Divide two numbers taking input from the user.
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int num1, num2, div;
7+
printf("Enter the first number: \n");
8+
scanf("%d", &num1);
9+
10+
printf("Enter the second number: \n");
11+
scanf("%d", &num2);
12+
13+
div = num1 / num2;
14+
15+
/*
16+
Important Note:
17+
Here, as data type we used integer data type. So whatever happes it will only show the integer part of the result.
18+
For example, if we devide 5 by 2 then the answer shoul be 2.5 but this program will show that 2.
19+
Preferred data type for such programs: float.
20+
*/
21+
22+
printf("Division of the two numbers: %d \n", div);
23+
24+
return 0;
25+
}

Arithmetic Problems/division.exe

383 KB
Binary file not shown.

Arithmetic Problems/division_float.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Divide two numbers taking input from the user.
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
float num1, num2, div;
7+
printf("Enter the first number: \n");
8+
scanf("%f", &num1);
9+
10+
printf("Enter the second number: \n");
11+
scanf("%f", &num2);
12+
13+
div = num1 / num2;
14+
15+
printf("Sum of the two numbers: %f \n", div);
16+
17+
return 0;
18+
}
383 KB
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Divide two numbers taking input from the user.
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
float num1, num2, div;
7+
printf("Enter the first number: \n");
8+
scanf("%f", &num1);
9+
10+
printf("Enter the second number: \n");
11+
scanf("%f", &num2);
12+
13+
/*
14+
If you calculate any number/0 that can't be calculate normally.
15+
So, it will show math error.
16+
*/
17+
if (num2 !=0)
18+
{
19+
div = num1 / num2;
20+
printf("Sum of the two numbers: %f \n", div);
21+
}
22+
else
23+
{
24+
printf("Math error!");
25+
}
26+
27+
return 0;
28+
}
383 KB
Binary file not shown.

Arithmetic Problems/multiplication.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// multiply two numbers taking input from the user.
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int num1, num2, mul;
7+
printf("Enter the first number: \n");
8+
scanf("%d", &num1);
9+
10+
printf("Enter the second number: \n");
11+
scanf("%d", &num2);
12+
13+
mul = num1 * num2;
14+
15+
printf("Multiplication of the two numbers: %d \n", mul);
16+
17+
return 0;
18+
}
383 KB
Binary file not shown.

0 commit comments

Comments
 (0)