៦. បញ្ចូល និងវាយដំលៃចំនាត់ថ្នាក់សិស្ស¶
លំហាត់ទី៦¶
- សរសេរកម្មវិធី បញ្ចូលពិន្ទុសិស្ស និងបង្ហាញលទ្ធផលលើscreen។
- ខ្សោយណាស់ ពី ០ទៅ ៣
- ខ្សោយ ៤
- មធ្យម ពី៥ ទៅ៦
- បង្គួរ ពី ៧ទៅ ៨
- ពូកែ ពី ៩ទៅ ១០
- វាយខុស បើដំលៃខុសពីនឹង។
- ផ្ដល់ជម្រើស វាយឡើងវិញ ឬបញ្ឈប់។
Source¶
#include <stdio.h>
#include <stdlib.h>
int main(){
float score;
tt : printf("Enter data:\n");
printf("Enter the student's score: ");
scanf("%f", &score);
if((score >= 0) && (score <= 3)) printf("Very poor");
else if( score == 4) printf("Poor");
else if((score >= 5) && (score <= 6)) printf("Faire");
else if((score >=7) && (score <= 8)) printf("Pretty good");
else if((score >=9) && (score <= 10)) printf("Very good");
else printf("Entered wrong!!!\n");
printf("\nContinue type 1 / stop type 0: ");
scanf("%f", &score);
if(score == 1) goto tt;
else
printf("Bye!\n");
}
Output¶
Enter data:
Enter the student's score: 5
Faire
Continue type 1 / stop type 0: 1
Enter data:
Enter the student's score: 9
Very good
Continue type 1 / stop type 0: 1
Enter data:
Enter the student's score: 4
Poor
Continue type 1 / stop type 0: 1
Enter data:
Enter the student's score: 2.5
Very poor
Continue type 1 / stop type 0: 0
Bye!