﻿

# C Program

Dec 3rd, 2020
919
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include<stdio.h>
2.
3. // 5. Write a C program that accepts two input numbers and compute the sum, difference, product, and quotient.
4. /*
5.     OUTPUT:
6.     Enter first number: 3
7.     Enter second number: 6
8.     Sum: 9
9.     Difference: -3
10.     Product: 18
11.     Quotient: 0.5
12. */
13. int main () {
14.     int num1, num2;
15.     printf("Enter first number: ");
16.     scanf("%d", &num1);
17.     printf("Enter first number: ");
18.     scanf("%d", &num2);
19.
20.     int sum = num1 + num2;
21.     printf("\nSum: %d", sum);
22.
23.     int difference = num1 - num2;
24.     printf("\nDifference: %d", difference);
25.
26.     int product = num1 * num2;
27.     printf("\nProduct: %d", product);
28.
29.     float quotient = (float)num1 / (float)num2;
30.     printf("\nQuotient: %.1f", quotient);
31.     return 0;
32. }
33.
34.
35. #include<stdio.h>
36.
37. // 8. Write a C program that accepts two input numbers and compute the sum, difference, product, and quotient.
38. /*
39.     Output (a):
40.
42.     Enter revenue: 515.50
43.     Commision rate is 4%
44.     Your total commission is 20.62
45.     ________________________________
46.     Output (b):
47.
49.     Enter revenue: 8000
50.     Commision rate is 5%
51.     Your total commision is 400
52.     ________________________________
53.     Output (c):
54.
56.     Enter revenue: 250400.20
57.     Commision rate is 10%
58.     Your total commision is 25040.02
59.     ________________________________
60.     NOTE: Try as much to reduce the decimal places by 2 (.00)
61. */
62. int main () {
63.     char name[30];
64.     float revenue;
65.     float commisionRate = 0;
66.
68.     scanf("%s", &name);
69.     printf("Enter revenue: ");
70.     scanf("%f", &revenue);
71.
72.     if (revenue <= 999.99) {
73.         commisionRate = 0.04; // 4% ---> 4 / 100 = 0.04 based on the table
74.     }
75.     else if (revenue>= 1000 && revenue <= 9999.99) {
76.         commisionRate = 0.05; // 5%
77.     }
78.     else if (revenue>= 10000 && revenue <= 49999.99) {
79.         commisionRate = 0.06; // 6%
80.     }
81.     else if (revenue>= 50000 && revenue <= 99999.99) {
82.         commisionRate = 0.07; // 7%
83.     }
84.     else if (revenue>= 100000 && revenue <= 999999.99) {
85.         commisionRate = 0.1; // 10%
86.     }
87.
88.     float commissionPercent = commisionRate * 100;
89.     printf("Commision rate is %.f percent\n", commissionPercent);
90.
91.     float commision = revenue * commisionRate;
92.     printf("Your total commision is %.2f\n", commision);
93.
94.     return 0;
95. }
96.
97.
98. #include<stdio.h>
99.
100. // 8. bag manufacturing company gives incentives to employees based on the percentage of
101. //    quota attainment. Write a C program that computes the incentive amount based on the
102. //    input quota percentage. Assume that the target quota is 100,000 pesos. Use the table
103. //    below for reference.
104. /*
105.     Output (a):
106.
107.     Enter your quota percentage(%): 15
108.     Your total incentive is 10000 (10%)
109.     ________________________________
110.     Output (b):
111.
112.     Enter your quota percentage(%): 25
113.     Your total incentive is 20000 (20%)
114.     ________________________________
115.     Output (c):
116.
117.     Enter your quota percentage(%): 89
118.     Your total incentive is 50000 (50%)
119.     ________________________________
120. */
121. int main () {
122.     float quota = 100000;
123.
124.     int quotaPercentage;
125.     float totalIncentive = 0;
126.
127.     float incentiveRate;
128.     float incentivePercent;
129.
130.     printf("Enter your quota percentage(percent): ");
131.     scanf("%d", &quotaPercentage);
132.
133.     if (quotaPercentage >= 0 && quotaPercentage <= 20) {
134.         incentiveRate = 0.1; // 0.1 ---> 10% based on  table
135.     }
136.     else if (quotaPercentage >= 21 && quotaPercentage <= 40) {
137.         incentiveRate = 0.2; // 0.2
138.     }
139.     else if (quotaPercentage >= 41 && quotaPercentage <= 60) {
140.         incentiveRate = 0.3; // 0.3
141.     }
142.     else if (quotaPercentage >= 61 && quotaPercentage <= 80) {
143.         incentiveRate = 0.4; // 0.4
144.     }
145.     else if (quotaPercentage >= 81 && quotaPercentage <= 100) {
146.         incentiveRate = 0.5; // 0.5
147.     }
148.     else if (quotaPercentage > 100) {
149.         incentiveRate = 0.6; // 0.6
150.     }
151.
152.     totalIncentive = quota * incentiveRate;
153.     incentivePercent = incentiveRate * 100;
154.
155.     printf("Your total incentive is %.f (%.f percent)", totalIncentive, incentivePercent);
156.
157.     return 0;
158. }
159.
160.
RAW Paste Data