Question

Task 2) Write and execute a C program using any C compiler to input students number of previous semesters attended and marks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer-a)

#include<stdio.h>
int main()
{
int marks; // variable marks
printf("Enter your marks ");
scanf("%d",&marks);
if(marks<0 || marks>100)
{
printf("Wrong Entry");
}
else if(marks<50) // marks is less than 50
{
printf("Grade of student is Fail");
}
else if(marks>=50 && marks<70) //marks is greater than 50 and less than 70
{
printf("Grade of student is D");
}
else if(marks>=70 && marks<91)//marks is greater than 70 and less than 91
{
printf("Grade of student is B");
}
  
else if(marks>=91 && marks<100)
{
printf("Grade of student is A");
}
return 0;
}
  
Output-
Enter your marks 92
Grade of student is A

Enter your marks 80
Grade of student is B

Enter your marks 55
Grade of student is D

Enter your marks 40
Grade of student is Fail
{ 9 1 #include<stdio.h> 2 int main() 3-{ 4 int marks; // variable marks 5 printf(Enter your marks ); 6 scanf(%d,&marks);else if(marks >=91 && marks<100) { 23 24 25 26 27 28 29 } printf(Grade of student is A); Y return 0; output- Enter your marAnswer-b)

#include<stdio.h>
int main()
{ char grade;
printf("Enter Grade( A or B or D ): ");
scanf("%c",&grade);
switch( grade )
{
case 'A':
printf("GPA=4");
break;
case 'B':
printf("GPA=2");
break;
case 'D':
printf("GPA=1");
break;
default:
printf("GPA=0");
break;
}
return 0;
}
Output-
Enter Grade( A or B or D ): B
GPA=2

4 8 1 #include<stdio.h> 2 int main() 3. { char grade; printf(Enter Grade A or B or D): ); 5 scanf(%c,&grade); 6 switch( gAnswer-c)

6 1 #include<stdio.h> 2 int main() 3. { int GPA1, GPA2, GPA3, GPA4; 4 float average; 5 printf(Enter GPA for grade A ); scan

Answer-d)

1) Pseudocode for a)-

1. if(marks<0 || marks>100) then
2. display wrong entry
3. else if(marks<50)
4. result = "Fail" ' display "F"
5. else if(marks>=50 && marks<70)
6. result = "D" ' display "D"
7. else if(marks>=70 && marks<91)
8. result = "B" ' display "B"
9. else if(marks>=91 && marks<100)
10. result = "A" ' display "A"
11. End If

1) Pseudocode for b)-

1.Input a Grade
2.Case based on Grade
Case ='A'
display “GPA=4”
Case ='B'
display “GPA=2”
Case ='D'
display “GPA=1”
Default
display “GPA=0”
3.End Case

1) Pseudocode for c)-

1. Read GPA

2. Sum GPA.

3. Average=sum/4

4. Display Average

Answer-2)

Flowchart for a)

Flow chart start Read marks marks>=91 marks >=70 and <91 marks >=50 and <70 Display fail Display grade =A Display grade =B DiFlowchart for b)-

enter grade true grade=A GPA=4 false true grade=B GPA=2 false true grade=D GPA=1 false GPA=0

Flowchart of CGPA-

Flow chart start Read GPA Average Display CGPA stop

Add a comment
Know the answer?
Add Answer to:
Task 2) Write and execute a C program using any C compiler to input students' number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python Program Display the grades: Input: Enter the marks of the student Condition: Grade...

    Write a Python Program Display the grades: Input: Enter the marks of the student Condition: Grade A: Marks greater than 90 Grade B: Marks range from 81 to 90 Grade C: Marks range from 65 to 80 Fail: less than 65 Display the output. Example: Input: 95 Display: “student got Grade A” Input: 80 Display: “student got Grade C” Input: 64 Display: “student failed” Hint: Use else if (elif and logical operators)

  • using C geany. Please Dr. exercise # 1 and 2 During the lab: PART I: PROGRAMMING...

    using C geany. Please Dr. exercise # 1 and 2 During the lab: PART I: PROGRAMMING EXERCISES a. Using Geany, write a C program that prompts and asks the user for two assignment marks (al and a2) and two test marks (ti and t2). All four variables are integer variables and are in % (out of 100). You program should display the four marks properly lalebed to check if the input has been successful. b. Next, calculate and display the...

  • Write a C++ program to store and update students' academic records in a binary search tree....

    Write a C++ program to store and update students' academic records in a binary search tree. Each record (node) in the binary search tree should contain the following information fields:               1) Student name - the key field (string);               2) Credits attempted (integer);               3) Credits earned (integer);               4) Grade point average - GPA (real).                             All student information is to be read from a text file. Each record in the file represents the grade information on...

  • Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program...

    Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program of the following problem. This question involve repetition: while, and for statements This question involve selection: Don't use switch, use IF Marks is based on comments, indentation and interface/menu. You must try Choose any one value of j to print screen the following i Three input: num less than j, 21 and any valid number three input: A, B and X. Question: 1.0 From...

  • Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at...

    Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at the top and at least one more good comment later in the program), to process data for the registrar as follows: NOTE: Include prompts. Send all output to the screen. 1. Read in the id number of a student, the number of credits the student has, and the student’s grade point average (this is a number like 3.25). Print the original data right after...

  • Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....

    Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...

  • using C language Programming Question 1 Write a C program that takes students marks from a...

    using C language Programming Question 1 Write a C program that takes students marks from a user, one by one until -1" is entered, which would indicate that no other marks are available, and the program terminates. For each mark the program will decide the student grade as: Fail, if mark < 60 • D. if 60<= mark <=70 • C. if 70<=mark <=80 • B. if 80c= mark <=90 • A. if 90cmark <=100 -T -- E - 15203...

  • In this homework, you will design a program to perform the following task: Write a program...

    In this homework, you will design a program to perform the following task: Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed. Design your program to calculate the Grade Point Average (GPA) for each student based on each of their final grades. The program should...

  • (Statistics) a. Write a C++ program that reads a list of double-precision scores from the keyboard...

    (Statistics) a. Write a C++ program that reads a list of double-precision scores from the keyboard into an array named scores. It is assumed that the user will enter no more than 35 scores. The scores are to be counted as they're read, and entry is to be terminated when a negative value has been entered. After all scores have been input, your program should find and display the sum and average of the scores. The scores should then be...

  • Write a program using "C" in visual studio that: A. Has a function (input()) that allows...

    Write a program using "C" in visual studio that: A. Has a function (input()) that allows the user to enter a list of 10 scores and stores them in an array. B. Has a function (result()) then assigns grades based on the following sheme: 21 Write a program that a Has a function (iaoutO) that allows the user to enter a list of 10 scores and stores therm in an array b. Has a function (resultil then assigns gracdes besed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT