saving . . . saved Relational Operators assignment has been deleted. Relational Operators assignment has been hidden .
Relational Operators assignment
Title
Question
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.

C-and-Cpp Relational-Operators 08-09 min 30-40 sec 03-06-22, 5:10 p.m. adarashkumar9002@gmail.com

Answers:

A meaningful program can be written as follows:
#include <stdio.h>
int main()
{
    int m1,m2,m3;
    printf("Enter the marks of student 1\n");
    scanf("%d %d %d",&m1,&m2,&m3);
    if(m1 > m2 & m1 > m3)
    printf("student 1 got the highest marks of %d \n",m1);
    else if (m2 > m1 & m2 > m3)
    printf("student 2 got the highest marks of %d \n",m2);
    else if (m3 > m1 & m3 > m2)
    printf("student 3 got the highest marks of %d \n",m3);
    if(m1 == m2 & m1== m3)
    printf("same marks has been received by the students\n");
    else if (m1==m2)
     printf("same marks has been received by the students 1 and 2\n");
    else if (m1==m3)
     printf("same marks has been received by the students 1 and 3\n");
    else if (m2==m3)
     printf("same marks has been received by the students 2 and 3\n");
    return 0;
}
06-06-22, 12:58 p.m. hbammkanti


<font size="4">Program in c to compare the marks of the students;</font>


#include<stdio.h>

int main()
{
    int a,b,c;
    printf("Enter the marks of student1 , student2 and student3\n");
    scanf("%d %d %d",&a,&b,&c);
    if ((a>b)&&(a>c))
    printf("student1 has highest marks\n");
    else if (b>c)
    printf("student2 has highest marks\n");
    else
    printf("student3 has highest marks\n");
    if ((a==b)&&(b==c)&&(a==c))
    printf("Three students have equal marks\n");
    else if ((a==b)||(a==c)||(b==c))
    printf("Two students have equal marks\n");
    else
    printf("No students have equal marks\n");
    return 0;
}

Output:

Enter the marks of student1 , student2 and student3
35
44
35
student2 has highest marks
Two students have equal marks

<font size="4">Program in c to compare the marks of the students;</font>


#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cout<<"Enter the marks of student1 , student2 and student3"<<"\n";
    cin>>a>>b>>c;
    if ((a>b)&&(a>c))
    cout<<"student1 has highest marks"<<"\n";
    else if (b>c)
    cout<<"student2 has highest marks"<<"\n";
    else
    cout<<"student3 has highest marks"<<"\n";
    if ((a==b)&&(b==c)&&(a==c))
    cout<<"Three students have equal marks"<<"\n";
    else if ((a==b)||(a==c)||(b==c))
    cout<<"Two students have equal marks"<<"\n";
    else
    cout<<"No students have equal marks"<<"\n";
    return 0;
}

Output:

Enter the marks of student1 , student2 and student3
35
44
35
student2 has highest marks
Two students have equal marks




23-01-24, 5:19 p.m. Vaishnavi2885


#include<stdio.h>
Void main()
{
    int a,b,c;
    printf("Enter the marks of student 1 , student 2 and student 3: \n");
    scanf("%d %d %d",&a,&b,&c);
    if ((a>b)&&(a>c))
    printf("student 1 has highest marks\n");
    else if (b>c)
    printf("student 2 has highest marks\n");
    else
    printf("student 3 has highest marks\n");
    if ((a==b)&&(b==c)&&(a==c))
    printf("Three students have equal marks\n");
    else if ((a==b)||(a==c)||(b==c))
    printf("Two students have equal marks\n");
    else
    printf("No students have equal marks\n");
}
Output:
Enter the marks of student 1,student 2 and student 3:
100 98 97
Student 1 has highest marks

11-08-24, 8:37 p.m. 238T1A05D9


#include<stdio.h>
int main()
{
    int a, b, c;
    printf("enter the marks of student 1, student 2, and student 3:\n");
    scanf("%d,%d,%d",&a,&b,&c);
    if((a>b)&&(a>c))
    printf("student 1 has highest marks\n");
    else if (b>c)
    printf("student 2 has highest marks\n");
    else
    printf("student 3 has highest marks\n");
    if ((a==b)&&(b==c)&&(c==a))
    printf("three students have equal marks\n");
    else if ((a==b)||(b==c)||(a==c))
    printf("two students have equal marks\n");
    else
     printf("no students have equal marks\n");
     return 0;
}

   output:
   enter the marks of student 1 student 2 and student 3:
   30,60,79
   student 3 has highest marks
12-08-24, 2:38 p.m. Nikki5D4


#include<stdio.h>
int main()
{
    int a, b, c;
    printf("enter the marks of student 1, student 2, and student 3:\n");
    scanf("%d,%d,%d",&a,&b,&c);
    if((a>b)&&(a>c))
    printf("student 1 has highest marks\n");
    else if (b>c)
    printf("student 2 has highest marks\n");
    else
    printf("student 3 has highest marks\n");
    if ((a==b)&&(b==c)&&(c==a))
    printf("three students have equal marks\n");
    else if ((a==b)||(b==c)||(a==c))
    printf("two students have equal marks\n");
    else
     printf("no students have equal marks\n");
     return 0;
}

   output:
   enter the marks of student 1 student 2 and student 3:
   30,60,79
   student 3 has highest marks
12-08-24, 3:01 p.m. tanmayi.P


#include<stdio.h>
Void main()
{
    int a,b,c;
    printf("Enter the marks of student 1 , student 2 and student 3: \n");
    scanf("%d %d %d",&a,&b,&c);
    if ((a>b)&&(a>c))
    printf("student 1 has highest marks\n");
    else if (b>c)
    printf("student 2 has highest marks\n");
    else
    printf("student 3 has highest marks\n");
    if ((a==b)&&(b==c)&&(a==c))
    printf("Three students have equal marks\n");
    else if ((a==b)||(a==c)||(b==c))
    printf("Two students have equal marks\n");
    else
    printf("No students have equal marks\n");
}
Output:
Enter the marks of student 1,student 2 and student 3:
100 98 97
Student 1 has highest marks
12-08-24, 3:04 p.m. 238T1A05D3


#include<stdio.h>
int main()
{
    int a, b, c;
    printf("enter the marks of student 1, student 2, and student 3:\n");
    scanf("%d,%d,%d",&a,&b,&c);
    if((a>b)&&(a>c))
    printf("student 1 has highest marks\n");
    else if (b>c)
    printf("student 2 has highest marks\n");
    else
    printf("student 3 has highest marks\n");
    if ((a==b)&&(b==c)&&(c==a))
    printf("three students have equal marks\n");
    else if ((a==b)||(b==c)||(a==c))
    printf("two students have equal marks\n");
    else
     printf("no students have equal marks\n");
     return 0;
}

   output:
   enter the marks of student 1 student 2 and student 3:
   30,60,79
   student 3 has highest marks
12-08-24, 3:15 p.m. Shalini_09


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the marks of the students:");
scanf("%d%d%d",&a,&b,&c);
if(a>b&a>c)
printf("a got highest marks of %d",a);
else if(b>c&b>a)
printf("b got highest marks of %d",b);
else 
printf("c got highest marks of %d",c);
if(a==b&a==c)
printf("a,b,c got same marks");
else if(a==b)
printf("a and b got same marks");
else if(a==c)
printf("a and c got same marks");
else
printf("b and c got same marks");
getch();
}
output
enter the marks of the students:100 98 97
a got highest marks of 100
12-08-24, 4:17 p.m. 238T1A05G7


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the marks of the students:");
scanf("%d%d%d",&a,&b,&c);
if(a>b&a>c)
printf("a got highest marks of %d",a);
else if(b>c&b>a)
printf("b got highest marks of %d",b);
else 
printf("c got highest marks of %d",c);
if(a==b&a==c)
printf("a,b,c got same marks");
else if(a==b)
printf("a and b got same marks");
else if(a==c)
printf("a and c got same marks");
else
printf("b and c got same marks");
getch();
}
16-08-24, 4:58 p.m. 238T1A05F5


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the marks of the students:");
scanf("%d%d%d",&a,&b,&c);
if(a>b&a>c)
printf("a got highest marks of %d",a);
else if(b>c&b>a)
printf("b got highest marks of %d",b);
else 
printf("c got highest marks of %d",c);
if(a==b&a==c)
printf("a,b,c got same marks");
else if(a==b)
printf("a and b got same marks");
else if(a==c)
printf("a and c got same marks");
else
printf("b and c got same marks");
getch();
}
19-08-24, 3:16 p.m. nasreensk2005@gmail.com


#include<stdio.h>
#include<conio.h>
Void main()
{
    int a,b,c;
    printf("Enter the marks of three students: \n");
    scanf("%d %d %d",&a,&b,&c);
    if ((a>b)&&(a>c))
    printf("a got highest marks of %d",a);
    else if (b>c)
    printf("b got highest marks of %d",b);
    else
    printf("c got highest marks of %d",c);
    if ((a==b)&&(b==c)&&(a==c))
    printf("Three students have equal marks\n");
    else if ((a==b)||(a==c)||(b==c))
    printf("Two students have equal marks\n");
    else
    printf("No students have equal marks\n");
    getch();
}
Output:
enter the marks of three students:
95 98 99
c got highest marks of 99


24-08-24, 11:37 a.m. 238T1A05G1


Log-in to answer to this question.