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()
}
Login to add comment