C
This commit is contained in:
parent
5bae8be9fe
commit
b9492bb8d7
20
DeitelC/BonusInstructor.c
Normal file
20
DeitelC/BonusInstructor.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int total = 0;
|
||||
int grade = 0;
|
||||
int pass = 0;
|
||||
int fail = 0;
|
||||
|
||||
while(total < 10) {
|
||||
printf("%s","Enter grade (grades must be 1 or 2 !) ");
|
||||
scanf("%d", &grade);
|
||||
if(grade == 1) {
|
||||
fail = fail + 1;
|
||||
} else {
|
||||
pass = pass + 1;
|
||||
}
|
||||
total = total + 1;
|
||||
}
|
||||
puts((pass >= 8) ? "Bonus to Instructer!" : "");
|
||||
}
|
31
DeitelC/ClassAvarage.c
Normal file
31
DeitelC/ClassAvarage.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int total = 0;
|
||||
int counter = 0;
|
||||
|
||||
printf("%s","Enter grades!, -1 to End: ");
|
||||
int grade = 0;
|
||||
scanf("%d", &grade);
|
||||
while(grade != -1) {
|
||||
total = total + grade;
|
||||
counter = counter + 1;
|
||||
|
||||
printf("%s", "Enter grades!, -1 to End: ");
|
||||
scanf("%d", &grade);
|
||||
}
|
||||
|
||||
if (counter != 0) {
|
||||
|
||||
double avarage = (double) total / counter;
|
||||
|
||||
printf("Class average is %.2f\n", avarage);
|
||||
printf("%d ", total);
|
||||
printf("%d ", counter);
|
||||
printf("%.0f", avarage);
|
||||
|
||||
|
||||
} else {
|
||||
puts("Enter a valid number!");
|
||||
}
|
||||
}
|
15
DeitelC/ConditionalExpression.c
Normal file
15
DeitelC/ConditionalExpression.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int grade;
|
||||
printf("%s\n", "Enter your grade!");
|
||||
scanf("%d", &grade);
|
||||
if (grade >= 60) {
|
||||
printf("%s\n", "You passed!");
|
||||
|
||||
} else {
|
||||
printf("%s\n", "You failed!");
|
||||
printf("%d\n", grade);
|
||||
}
|
||||
printf((grade <= 60) ? "Fail" : "Passed");
|
||||
}
|
5
DeitelC/PseudocodeBonusInstructor.md
Normal file
5
DeitelC/PseudocodeBonusInstructor.md
Normal file
@ -0,0 +1,5 @@
|
||||
1- 10 results must entered!
|
||||
2- Each number 1 or 2 if number none of this than program only checks number = 1 if is not than program thinks
|
||||
it's 2
|
||||
3- Two counters are used one to count the number of students who passed and failed.
|
||||
4- After the results, if 8 students passed the exam and, if so, print "Bonus to Instructer!"
|
BIN
DeitelC/a.exe
Normal file
BIN
DeitelC/a.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user