Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What is wrong on this ?

0 votes
asked Mar 22, 2018 by Daniel Kishinsky (120 points)
#include <stdio.h>

#include <stdlib.h>

#define LICZBA_OCEN 5

float oceny[LICZBA_OCEN] = { 3, 3.5, 4.5, 5, 5 };

void

wyswietl (Student * student)

{

  

printf ("%s\n", (*student).imie_nazwisko);

  

int i;

  

for (i = 0; i < LICZBA_OCEN; i++)

    {

      

printf ("%.1f\n", (*student).ocena[i]);

    

}

  

float srednia (Student * student)

  {

    

float suma = 0;

    

int i;

    

for (i = 0; i < LICZBA_OCEN; ++i)

      

      {

suma = suma + (*student).oceny[i];

      

}

    

return /LICZBA_OCEN;

  

}

  

typedef struct

  {

    

char imie_nazwisko[50];

     

float oceny[LICZBA_OCEN];

   

}

Student s;

  

stropy (s.imie_nazwisko, "Novikov Oleksandr");

  

int main ()

  {

    

s.oceny[0] = 4.5;

    

s.oceny[1] = 5;

    

s.oceny[2] = 3.5;

    

s.oceny[3] = 3;

    

s.oceny[4] = 5;

    

wyswietl (&s);

    

printf ("Srednia: %.2f", srednia (&s));

  

}

2 Answers

0 votes
answered Mar 22, 2018 by Héctor Murcia Forero (220 points)
0 votes
answered Mar 28, 2018 by John Gabriel (310 points)
You made a lot of mistakes. Here is the complete program:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define LICZBA_OCEN 5

struct Student
{ char imie_nazwisko[50];
  float oceny[LICZBA_OCEN];
};

float oceny[LICZBA_OCEN] = { 3, 3.5, 4.5, 5, 5 };

float wyswietl (Student * student)
{ printf ("%s\n", (*student).imie_nazwisko);
  int i;

  for (i = 0; i < LICZBA_OCEN; i++)
    {
     printf ("%.1f\n", (*student).oceny[i]);
    }
}

float srednia (Student * student)
{  float suma = 0;
   int i;
   for (i = 0; i < LICZBA_OCEN; ++i)
      {
        suma = suma + (*student).oceny[i];
      }
   return (float) LICZBA_OCEN;
}

Student s;

int main ()
{
    
strcpy (s.imie_nazwisko, "Novikov Oleksandr");
    
s.oceny[0] = 4.5;
s.oceny[1] = 5;
s.oceny[2] = 3.5;
s.oceny[3] = 3;
s.oceny[4] = 5;

wyswietl (&s);
printf ("Srednia: %.2f", srednia (&s));
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...