Like Tree1Likes
  • 1 Post By quzah

Array Help

This is a discussion on Array Help within the C Programming forums, part of the General Programming Boards category; Good Day, Actually, I am stuck with an assignment and I need help badly. I got a char check[] = ...

  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.
    itsme86 likes this.
    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, 10:26 PM
  2. Replies: 16
    Last Post: 05-29-2009, 08:25 PM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 08:31 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21