I seem to have trouble reading the input from the array

#include <stdio.h>
#include <conio.h>
#define ROW 1
#define COL 6

void printinfo(int[][COL],int,int);
void findId(int[][COL],int,int);

int sum=0;
float avg=0;

int main()
{
        int info[ROW][COL]={0};
        
        
        for(int x=0;x<ROW;x++)
        {
                 printf("\nEnter the students ID number:");
                 fflush(stdin);
                 scanf("%d",&info[x][0]);
                    
                for (int y=0;y<COL;y++)
                {
                                                           
                    printf("\nEnter the student grade:");
                    fflush(stdin);
                    scanf("%d",&info[x][y]);
                    }
                    }
                    
                    printinfo(info,ROW,COL);
                    findId(info,ROW,COL);
                    
                    getch();
                    return 0;
                    }


void printinfo(int a[][COL],int row,int col)
{
     for(int y=0;y<row;y++)
     {
             printf("\nThe student ID number is:%d",a[y][0]);
                          
                for(int x=0;x<col;x++)
                   {              
                   printf("\nThe student grades is:%d\n",a[y][x]);
                   sum+=a[row][col];
                      }
                      }     
}

void findId(int a[][COL],int row,int col)
{
     int num=0;
     
     printf("\nPlease enter the student Id to be find:");
     fflush(stdin);
     scanf("%d",&num);

     
     for(int y=0;y<row;y++)
     {
             printf("\nThe student ID number is:%d",num);
             
             if(num==a[row][col])
                  {
                                 printf("\nFound ID number");  
                                 break;                                                        
              
                      }
                      }   
          for (int x=0;x<col;x++) 
               printf("\nThe student grades are:%d",a[row][col]);            
                      
          avg=sum/5;
          
          printf("\nThe student average is:%f",avg);

}

There are 2-3 mistakes in your code
1. You are storing the id is a[0][0], yet when you start storing the marks of the students you start again from a[0][0], the index of the loop on line 23 should start from 1. This mistake is repeated again in the function printinfo.
2. In the function printinfo(), the code for adding all the grades is wrong. Your sum statement is basically adding a[1][6] 5 times. See how you printed the array and compare how you are adding them
3. You have made the same functions in a couple of place is the findinfo function as well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.