0
I need to insert 3 notes, average with 3 notes, then with the highest note and the second highest note , then with the highest note and the worst note.
#include<stdio.h>
int meio(int a, int b, int c)
{
if(a>b && a<c)
return a;
else
return b,c;
}
int menor (int a, int b, int c)
{
if (a<b && a<c)
return a;
else
return b,c;
}
int maior (int a, int b, int c)
{
if (a > b && a>c)
return a;
else
return b,c;
}
main()
{
float M,MDM;
int n1,n2,n3;
printf("\n primeira nota: ");
scanf("%d",&n1);
printf("\n segunda nota: ");
scanf("%d",&n2);
printf("\n terceira nota: ");
scanf("%d",&n3);
printf("\n Maior nota = %d",maior(n1,n2,n3));
printf("\n Menor nota = %d",menor(n1,n2,n3));
printf("\n Segunda maior nota=%d",meio(n1,n2,n3));
M=(n1+n2+n3)/3;
printf("\n media:%.2f",M);
}
What is your difficulty? Because you entered your code and what should be done but did not specify what you got stuck on. Edit your answer to get more detailed so we can help you out.
– José
then , I can’t separate the second highest note , I get the highest and the lowest , but not the second highest and I need to average the highest and lowest note , the highest and the second highest and dps of the 3 .
– Pedro Sabença
i was up there trying to put as if it were the second largest:int middle(int a, int b, int c) { if(a>b && a<c) Return a; Else Return b,c; }
– Pedro Sabença
What do you think
return b,c;
would make?– Victor Stafusa
Already tried to sort the three notes and then do
m=(a+b+c)/3;
,x=(a+b)/2;
,y=(a+c)/2;
andz=(b+c)/2;
?– Victor Stafusa
but as the program will separate the average of the highest notes , and the largest with the lowest ?
– Pedro Sabença
Sorting the notes. If the first is larger than the second, you exchange the first with the second. If the first is larger than the third, you trade the first with the third. If the second is bigger than the third, you trade the second with the third.
– Victor Stafusa