0% found this document useful (0 votes)
18 views4 pages

Implementation 2

Uploaded by

mdmasummiah477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Implementation 2

Uploaded by

mdmasummiah477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Implementation:

[Link] Method Using else-if Ladder:


#include <stdio.h>
int main() {
int n;
printf("Enter your number: ");
scanf("%d", &n);
if (n >= 80 && n <= 100) {
printf("A\n");
} else if (n >= 60 && n <= 79) {
printf("B\n");
} else if (n >= 40 && n <= 59) {
printf("C\n");
} else {
printf("F\n");
}
return 0;
}
[Link] Method Using switch:
#include <stdio.h>

int main() {

int n;

int m;

printf("Enter your number: ");

scanf("%d", &n);

m = n / 10;

switch (m) {

case 10:

case 9:

case 8:

printf("A\n");

break;

case 7:

case 6:

printf("B\n");

break;

case 5:

case 4:

printf("C\n");

break;

default:

printf("F\n");

break;

return 0;

}
3. Grading Method Using Nested if statements:
#include <stdio.h>
int main() {
int n;
printf("Enter your number: ");
scanf("%d", &n);
if (n >= 40) {
if (n >= 60) {
if (n >= 80) {
printf("A\n");
} else {
printf("B\n");
}
} else {
printf("C\n");
}
} else {
printf("F\n");
}
return 0;
}
[Link] Statements:
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
if(n%2==0){
goto even;
}
else{
goto odd;
even:
printf("%d=even\n",n);
return;
odd:
printf("%d is odd",n);
}
return 0;
}

You might also like