This commit is contained in:
k0rrluna 2024-02-21 04:52:18 +03:00
parent 5bae8be9fe
commit b9492bb8d7
5 changed files with 71 additions and 0 deletions

20
DeitelC/BonusInstructor.c Normal file
View 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
View 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!");
}
}

View 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");
}

View 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

Binary file not shown.