- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Golang Program to read the marks of subjects and display the Grade
Let's enter the marks: 89 56 90 67 99
Sum of the marks is: 89+56+90+67+99 => 401
Avg. = 401/5 = 80.1
The steps are as follows:
- Define variables for 5 subjects.
- Enter marks for 5 subjects.
- Find average of the marks to find grade.
- Use if else block to print grade.
Example
package main import "fmt" func main(){ var sub1, sub2, sub3, sub4, sub5 int fmt.Println("Enter marks of the five subjects:") fmt.Scanf("%d", &sub1) fmt.Scanf("%d", &sub2) fmt.Scanf("%d", &sub3) fmt.Scanf("%d", &sub4) fmt.Scanf("%d", &sub5) avg:=(sub1+sub2+sub3+sub4+sub5)/5 if avg>=90{ print("Grade: A") }else if avg>=80 && avg<90{ print("Grade: B") }else if avg>=70 && avg<80{ print("Grade: C") }else if avg>=60 && avg<70{ print("Grade: D") } else{ print("Grade: F") } }
Output
Enter marks of the five subjects: 89 56 90 67 99 Grade: B
- Related Articles
- Finding average marks of students for different subjects and display only the highest average marks in MySQL
- Golang Program to Read the Contents of a File
- Golang Program to Read Three Digits and Print all Possible Combinations from the Digits
- Golang Program to Read a Number (n) and Print the Natural Numbers Summation Pattern
- Golang Program to Read Two Numbers and Print their Quotient and Remainder
- Python program to display all second lowest grade student name from nested list
- Golang Program to Read a Number (n) and Compute (n+nn+nnn)
- In a class test, the sum of Shefali's marks in Mathematics and English is 30. Had she got 2 marks more in Mathematics and 3 marks less in English, the product of her marks would have been 210. Find her marks in two subjects.
- In a class test, the sum of the marks obtained by P in Mathematics and Science is 28. Had he got 3 marks more in Mathematics and 4 marks less in Science, the product of his marks, would have been 180. Find his marks in the two subjects.
- Write a C program to read a data from file and display
- Program to create grade calculator in Python
- Golang program to calculate the volume and area of the Cylinder
- How to project grouping into object in MongoDB and display only the marks field?
- How to read CSV files in Golang?
- Golang program to calculate the absolute and scale of a vertex.

Advertisements