[Solved] array inside function


#include<stdio.h>

#define MAX_SIZE_ALLOTED_TO_EACH_QUESTION 100
#define NUMBER_OF_QUESTIONS 10

int scoreList[NUMBER_OF_QUESTIONS]; // This array will contain the individual score for each answers to respective questions
int i;

void Extroversion(int scoreList[]){

        // Let formula for this be E = 20 +(1)___-(3)___+(2)___-(4)___
        int E = 20 + (scoreList[1] + scoreList[2]) - (scoreList[3] + scoreList[4]);
        printf("\nExtroversion is the personality trait of seeking fulfillment from sources outside the self or in community. High scorers tend to be very social while low scorers prefer to work on their projects alone.\nYour score for this trait is: %d\n\n", E);
}

void Agreeableness(int scoreList[]){

        // Let formula for this be A = 14 -(2)___+(5)___-(3)___+(6)___
        int A = 20 + (scoreList[5] + scoreList[6]) - (scoreList[2] + scoreList[3]);
        printf("\nAgreeableness reflects much individuals adjust their behavior to suit others. High scorers are typically polite and like people. Low scorers tend to 'tell it like it is'.\nYour score for this trait is: %d\n\n", A);
}

/*

* Similarily for Conscientiousness, Neuroticism and Openness_to_Experience

*/


int main(){

        const char question[NUMBER_OF_QUESTIONS][MAX_SIZE_ALLOTED_TO_EACH_QUESTION] = { "1. Am the life of the party.", "2. Feel little concern for others.", "3. Am always prepared.", "4. Get stressed out easily.", "5. Have a rich vocabulary.", "6. Don't talk a lot.", "7. Am interested in people.", "8. Leave my belongings around.", "9. Am relaxed most of the time.", "10. Have difficulty understanding abstract ideas." };

        for(i=0; i<NUMBER_OF_QUESTIONS; i++){
                printf("%s :\nYour Score: ", question[i]);
                scanf("%d", &scoreList[i]); // Here each element is storing the value between 0-5 for their corresponsding question
 }

        Extroversion(scoreList);
        Agreeableness(scoreList);
//      Conscientiousness(scoreList);
//      Neuroticism(scoreList);
//      Openness_to_Experience(scoreList);

return 0;
}

I think it would be good for you to go through the code once. I have mentioned comments in the code using // and /* */. Read the comments properly. I have checked the code working for 10 questions on my system, so there would be no error if you complete following the pattern in which i have written. And don’t forget to look at the formula. The array index need to be according to the formula in the original pdf you have shared.

14

solved array inside function