If the marks obtained by a student in five different subjects are input through the
keyboard, write a program to find out the aggregate marks and percentage marks
obtained by the student. Assume that the maximum marks that can be obtained by a
student in each subject is 100.
in java only
Answers
Answer:
include<stdio.h>
#include<conio.h>
void main()
{
int hindi, math, english, science, art, total;
float percentage;
printf("Enter the marks of Hindi: ");
scanf("%d", &hindi);
printf("Enter the marks of Math: ");
scanf("%d", &math);
printf("Enter the marks of English: ");
scanf("%d", &english);
printf("Enter the marks of Science: ");
scanf("%d", &science);
printf("Enter the marks of Art: ");
scanf("%d", &art);
total = hindi+math+english+science+art;
percentage = total/5;
printf("\nAggregate marks: %d", total);
printf("\nPercentage marks: %0.2f %%", percentage);
getch();
}
Output:
Enter the marks of Hindi: 50
Enter the marks of Math: 50
Enter the marks of English: 50
Enter the marks of Science: 50
Enter the marks of Art: 60
Aggregate marks: 260
Percentage marks: 52.00 %
hope this helps you
Answer:
import java.util.*;
public class Question24
{
static void main()
{
Scanner sc=new Scanner(System.in);
int a,b,c,d,e,agg;
float perc;
System.out.println("Enter marks in 5 subjects: ");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
d=sc.nextInt();
e=sc.nextInt();
agg=a+b+c+d+e;
perc=(float)agg/500*100;
System.out.println("Aggregate Marks="+agg);
System.out.println("Percentage Marks="+perc);
}
}