first i enter only the ID, then the info about 4 students, after that according to the ID i entered at the beginning the info of one of those 4 students will be printed..i dont know if i explained it the right way..
and nope i dont know struct
I'm sorry can i ask you for one more thing? this program its a little bit complicated for me to understand all and in the answer i should send for example:
I type ID 538. then it says:
1
then i can continue to the next step..and i dont want that 1.
+ in the end i want output to be just in one line..
i tried to delete some things and here its what i left from the code(I also changed the names)
#include <stdio.h>
int main()
{
char classname[4][16];
int id[4];
int grade[4];
char name[4][4];
char surname[4][4];
int ID;
scanf("%d",&ID);
int i;
for(i = 0; i < 4; i++)
{
printf("%d\n",i+1);
scanf("%d",&id[i]);
scanf("%s",classname[i]);
scanf("%s",name[i]);
getchar();
scanf("%s",surname[i]);
getchar();
scanf("%d",&grade[i]);
}
//..SEARCH INDEX OF ID
printf("%d\n\n",ID);
for(i =0; i < 4; i++)
if(ID == id[i])
break;
#include <stdio.h>
int main()
{
char classname[4][16];
int id[4];
int grade[4];
char name[4][4];
char surname[4][4];
int ID;
scanf("%d",&ID);
int i;
for(i = 0; i < 4; i++)
{
//printf("%d\n",i+1); //remove the 1 you dont like
printf("\n\n"); //just to give a space between each new student input
scanf("%d",&id[i]);
scanf("%s",classname[i]);
scanf("%s",name[i]);
getchar();
scanf("%s",surname[i]);
getchar();
scanf("%d",&grade[i]);
}
//..SEARCH INDEX OF ID
printf("%d\n\n",ID);
for(i =0; i < 4; i++)
if(ID == id[i])
break;
if(i == 4)
printf("ID not found\n");
else
{
//removed '/n'
printf("%d %s %s %s %d\n",id[i], classname[i], name[i], surname[i], grade[i] );
}
}
i need to ask you for one more question..i know i suck, im sorry!
So the question is that a professor is teaching in two classes. There are two students in one class and three in the other. According to the informations I have to find the class with the highest average.
So the input should contain( You will be given five lines of information. In every line, you will have class name, student name, student surname, and student grade. Where class name is at most 3 characters containing only English letters or digit from 0 to 9. Name and surname are at most 15 characters containing only English letters. Student grade is an integer between 1 and 100.)
and here is my code(your code, i tried using what u sent me earlier since i thought it might be the same but im stucked now, dont know what to do next)
#include <stdio.h>
int main()
{
char classname[5][4];
char* name[5][16];
char* surname[5][16];
int grade[5];
int i;
for (i=0; i<5; i++)
{
scanf("%s",classname[i]);
scanf("%s", name[i]);
scanf("%s", surname[i]);
scanf("%d", &grade[i]);
}