C
This commit is contained in:
parent
f5aa8d53b6
commit
3a67cb72cc
28
DeitelC/IsPrime.c
Normal file
28
DeitelC/IsPrime.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void isPrime(int number) {
|
||||
int a = 1;
|
||||
int count = 0;
|
||||
|
||||
while (a < number) {
|
||||
if(number%a == 0) {
|
||||
count += 1;
|
||||
a++;
|
||||
} else {
|
||||
a++;
|
||||
}
|
||||
}
|
||||
|
||||
if(count == 1) {
|
||||
printf("%s\n", "Yes it's a Prime");
|
||||
|
||||
} else {
|
||||
printf("%s\n", "No it isn't a Prime");
|
||||
}
|
||||
}
|
||||
int main(void) {
|
||||
int number;
|
||||
printf("%s\n", "Enter a integer!");
|
||||
scanf("%d", &number);
|
||||
isPrime(number);
|
||||
}
|
46
DeitelC/Salary.c
Normal file
46
DeitelC/Salary.c
Normal file
@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(void) {
|
||||
printf("%s\n", "Enter # of hours worked (-1 to End):");
|
||||
int hours;
|
||||
scanf("%d", &hours);
|
||||
if (hours == -1) {
|
||||
return 0;
|
||||
};
|
||||
printf("%s\n","Enter hourly rate of the worker ($00.00):");
|
||||
float hourly;
|
||||
scanf("%f", &hourly);
|
||||
|
||||
if(hours <= 40) {
|
||||
while(hours != -1){
|
||||
printf("%s %.2f\n", "Salary is: ", hourly*hours);
|
||||
printf("%s\n", "Enter # of hours worked (-1 to End):");
|
||||
scanf("%d", &hours);
|
||||
if (hours == -1) {
|
||||
return 0;
|
||||
};
|
||||
printf("%s\n","Enter hourly rate of the worker ($00.00):");
|
||||
scanf("%f", &hourly);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (hours > 40) {
|
||||
while(hours != -1) {
|
||||
float OneHalf = ((hours - 40)*hourly)*(1,5);
|
||||
printf("%s %.2f\n", "Salary is :", 400+OneHalf);
|
||||
printf("%s\n", "Enter # of hours worked (-1 to End):");
|
||||
scanf("%d", &hours);
|
||||
if (hours == -1) {
|
||||
return 0;
|
||||
}
|
||||
printf("%s\n","Enter hourly rate of the worker ($00.00):");
|
||||
scanf("%f", &hourly);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
16
DeitelC/SalesCommision.c
Normal file
16
DeitelC/SalesCommision.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
|
||||
printf("%s\n", "Enter sales in dollars (-1 to end):");
|
||||
float sale;
|
||||
scanf("%f", &sale);
|
||||
|
||||
while (sale != -1) {
|
||||
printf("%s %.2f\n", "Salary is:", ((sale*9)/100)+200);
|
||||
printf("%s\n", "Enter sales in dollars (-1 to end):");
|
||||
scanf("%f", &sale);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
DeitelC/a.exe
BIN
DeitelC/a.exe
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user