assignment
Title
Question
<span style="color: rgb(85, 85, 85); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;">Write a program that takes the marks of three students as input. Compare the marks to see which student has scored the highest. Check also if two or more students have scored equal marks.</span>
C-and-Cpp Relational-Operators 08-09 min 40-50 sec
Answers:
Dear user,
Hint:
Take 3 variables and compare them. (> and >=or <, <=)
The assignment is for solving, Please go through the tutorial for similar example.
#include<iostream>
Using namespace std;
int main ()
{
int m1,m2,m3;
cout<<"Enter Marks of student";
cin>>m1>>m2>>m3;
int count=0;
int max=m1;
if(max<m2 )
{
max=m2;
}
if(max<m3)
{
max=m3;
}
If(m1==m2 && m2==m3)
{
count=3;
}
else if (m1==m2 || m2==m3 || m1==m3)
{
count=2;
}
cout<<"highest score is"<<max<<endl;
if (count>0)
{
cout<<count<<"student scored equal marks"<<endl;
}
else
{
cout<<"All student scored different marks";
}
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the a,b,c values");
scanf("%d%d%d",&a&b&c);
if(a>b&&a>c)
printf("a scored higher");
elseif(b>a&&b>c)
printf("b scored higher");
elseif(a==b==c)
printf("all scored equall");
else
printf("c scored higher");
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the a,b,c values");
scanf("%d%d%d",&a&b&c);
if(a>b&&a>c)
printf("a scored higher");
elseif(b>a&&b>c)
printf("b scored higher");
elseif(a==b==c)
printf("all scored equall");
else
printf("c scored higher");
getch();
}
#include<stdio,h>
void main()
{
int a,b,c;
printf("enter a,b,c values");
scanf("%d%d%d",&a,&b,&c);
if(a>=b)
{
if(a>=c)
printf("a is biggest");
else
print("c is biggest");
}
else
{
if(b>=c)
printf("b ic biggest");
else
printf("c ic biggest");
}
}
#include<stdio,h>
void main()
{
int a,b,c;
printf("enter a,b,c values");
scanf("%d%d%d",&a,&b,&c);
if(a>=b)
{
if(a>=c)
printf("a is biggest");
else
print("c is biggest");
}
else
{
if(b>=c)
printf("b is biggest");
else
printf("c is biggest");
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the a,b,c values");
scanf("%d%d%d",&a&b&c);
if(a>b&&a>c)
printf("a scored higher");
elseif(b>a&&b>c)
printf("b scored higher");
elseif(a==b==c)
printf("all scored equall");
else
printf("c scored higher");
getch()
}
#include <stdio.h>
int main()
{
int s1, s2, s3;
// Input marks of three students
printf("Enter marks of Student 1: ");
scanf("%d", &s1);
printf("Enter marks of Student 2: ");
scanf("%d", &s2);
printf("Enter marks of Student 3: ");
scanf("%d", &s3);
// Check who scored the highest
if (s1 > s2 && s1 > s3)
printf("Student 1 scored the highest.\n");
else if (s2 > s1 && s2 > s3)
printf("Student 2 scored the highest.\n");
else if (s3 > s1 && s3 > s2)
printf("Student 3 scored the highest.\n");
else if (s1 == s2 && s2 == s3)
printf("All three students scored equal marks.\n");
else if (s1 == s2 && s1 > s3)
printf("Student 1 and Student 2 scored equal highest marks.\n");
else if (s1 == s3 && s1 > s2)
printf("Student 1 and Student 3 scored equal highest marks.\n");
else if (s2 == s3 && s2 > s1)
printf("Student 2 and Student 3 scored equal highest marks.\n");
else
printf("Two or more students have equal marks.\n");
return 0;
}

Login to add comment