Thread: Array Help

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Array Help

    Good Day,

    Actually, I am stuck with an assignment and I need help badly.

    I got a char check[] = "TFFTF"

    and I should receive an input on the number of students

    Number of Students: 2

    Enter name and answer: Mary TFTTT
    Enter name and answer: Leo TFTFT

    output:
    Name Score
    Mary 3
    Leo 2

    I got no problems with the output, just the basic going inside my array.
    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
    	char correct[] = "TFFFTFTFTTFTFTF";
    	char name[10][51];
    	char answers[10][51];
    	int numStudents = 0;
    	int loop, loop2;
    
    
    	printf("Please enter the number of students >");
    	scanf("%d", &numStudents);
    
    	for(loop = 0; loop < numStudents;loop++)
    	{
    		printf("Please Enter student %d name and answer >", loop + 1);
    		scanf("%s %s", &name[loop][0], &answers[loop][0]);
    
    		for(loop2 = 0; loop2 < strlen(correct); loop2++)
    		{
    			printf("%s",answers[loop][0]);
    		}
    	}
    this is my current code. please help me solve it. I know my array is a mess. any hint or tip is gladly appreciated.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    for each element in the answer sheet
        if student answer equals answer sheet
            correct++
        else
            incorrect++

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multidimensional Array Addressing
    By BlackOps in forum C Programming
    Replies: 11
    Last Post: 07-21-2009, 09:26 PM
  2. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM