What's new

C & C++ Pa help po C language

velvetred

Eternal Poster
Joined
May 4, 2022
Posts
704
Solutions
17
Reaction
1,244
Points
444
Kulang nalang po ng ganito
1652191928333.png


C:
#include <stdio.h>

#define rSize 3
#define cSize 4

void accScores(int scores[rSize][cSize]){
    int row, col;
    
    for(row = 0; row < rSize; row++){
        printf("\nStudent %d:\n", row+1);
        for(col = 0; col < cSize; col++){
            printf("Quiz %d: ", col+1);
            scanf("%d", &scores[row][col]);
        }
    }
}

void scoresDisplay(int scores[rSize][cSize]){
    int row, col;
    
    for(row = 0; row < rSize; row++){
        printf("\nStudent %d: \n", row+1);
        for(col = 0; col < cSize; col++){
            printf("\nQuiz %d: %d\n", col+1, scores[row][col]);
        }
    }
    printf("\n");
}


main(){
    int scores[rSize][cSize];
    int type;
    
    printf("Input the scores of 3 students in the 4 quizzes;");
    accScores(scores);
    
    printf("Scores of all students:\n\n");
    scoresDisplay(scores);
}
 

Attachments

Last edited:
nag tataka lang ako bat c for beginner? pwede naman mga high level language (like python and javascript) para mas madali🙄
 
nag tataka lang ako bat c for beginner? pwede naman mga high level language (like python and javascript) para mas madali🙄
C at C++ din sa amin nung 1st year pa lang ako, ang advantage niyan ay mapa-pamilyar sa syntax ng C-family (curly braces, semi-colons), puwede na later on sa C#, Java, Javascript.
 
kaya nga bat hindi javascript nalang curly syntax din naman😅
C at C++ din sa amin nung 1st year pa lang ako, ang advantage niyan ay mapa-pamilyar sa syntax ng C-family (curly braces, semi-colons), puwede na later on sa C#, Java, Javascript.

hmmm baka mahirap kasi i re make yung mga activity🤔 baka nga
 
Ito ang ginawa ko para ma satisfy ang mga requirements. Nasa Student_Scores.txt ang code dahil di ko alam paano mag insert ng code snippet dito.

Main Menu
1652243824717.png


Option 1
1652243848958.png

Option 2
1652243873107.png
1652243891420.png

Option 3
1652243922316.png
1652243935496.png

Option 4
1652243957311.png

C:
#include <stdio.h>
#include <stdlib.h>

#define rSize 3
#define cSize 4

void accScores(int [rSize][cSize]);

void Menu(int [rSize][cSize]);
void disp_allScore(int [rSize][cSize]);
int pick_student(); //Pick which of the student
void disp_specScore(int [rSize][cSize], int); //Display Specific Student's score
void disp_specAvgScore(int [rSize][cSize], int); //Display Specific Student's Average Score
void disp_quizStat(int [rSize][cSize]); //Display Quiz Statistics

void accScores(int scores[rSize][cSize]){
    int row, col;
    
    for(row = 0; row < rSize; row++)
    {
        printf("\nStudent %d:\n", row+1);
        
        for(col = 0; col < cSize; col++)
        {
            printf("Quiz %d: ", col+1);
            scanf("%d", &scores[row][col]);
        }
    }
}

int main(){
    int scores[rSize][cSize];
    int type;
    
    
    
    printf("Input the scores of 3 students in the 4 quizzes;");
    accScores(scores);
    
    
    Menu(scores);
    
    return 0;
}

void Menu(int scores[rSize][cSize])
{
    system("cls");
    int x;
    do
    {
        printf("==================\n");
        printf("[1] Display All Scores\n");
        printf("[2] Display Scores of a specific student\n");
        printf("[3] Display Average Score of a specific student\n");
        printf("[4] Display Quiz Statistics\n");
        printf("[0] exit\n");
        printf("==================\n");
        printf("Your choice ==> ");
        scanf("%d", &x);
        system("cls");
    }while(x<0 || x>4);
    
    switch(x)
    {
        case 0:
        {
            break;
        }
        case 1:
        {
            disp_allScore(scores);
            Menu(scores);
            break;
        }
        case 2:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 3:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specAvgScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 4:
        {
            disp_quizStat(scores);
            Menu(scores);
            break;
        }
    }
}

void disp_quizStat(int scores[rSize][cSize])
{
    int i, j;
    float total_avg = 0;
    printf("Quiz Statistics\n");
    printf("===============================================\n");
    printf("Quiz\t\tAverage\tHighest\tLowest");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        float avg = 0;
        int high, low;
        high = low = scores[0][i];
        for(j=0; j<rSize; j++)
        {
            int temp = scores[j][i];
            avg += temp;
            if(temp > high)
            {
                high = temp;
            }
            
            if(temp < low)
            {
                low = temp;
            }
        }
        total_avg += avg/4;
        printf("\nNo. %d\t\t%.2f\t%d\t%d\n", i+1, avg/4, high, low);
    }
    printf("\nTotal Quiz Average Score: %.2f\n", total_avg/4);
    printf("\n===============================================\n");
    getwchar();
    getchar();
}

void disp_specAvgScore(int scores[rSize][cSize], int x)
{
    int i;
    float avg = 0;
    printf("Student Average Score");
    printf("\n===============================================\n");
    printf("Student\t\tAverage Score");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        avg += scores[x-1][i];
    }
    printf("\nNo. %d\t\t%.2f", x, avg/4);
    printf("\n===============================================\n");
    getchar();
    getchar();
    
}

void disp_allScore(int scores[rSize][cSize])
{
    int i, j;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4");
    printf("\n===============================================");
    for(i=0; i<rSize; i++)
    {
        printf("\nNo. %d\t", i+1);
        for(j=0; j<cSize; j++)
        {
            printf("\t%d", scores[i][j]);
        }
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

void disp_specScore(int scores[rSize][cSize], int x)
{
    int i;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4\n");
    printf("===============================================\n");
    printf("No. %d\t", x);
    for(i=0; i<cSize; i++)
    {
        printf("\t%d", scores[x-1][i]);
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

int pick_student()
{
    int x;
    do
    {
        printf("Choose which student's score to display.\n");
        printf("=========================================\n");
        printf("[1] Student 1\n");
        printf("[2] Student 2\n");
        printf("[3] Student 3\n");
        printf("[0] Exit\n");
        printf("=========================================\n");
        scanf("%d", &x);
    }while(x<0 || x>3);
    
    return x;
}
 

Attachments

Last edited:
Thank
Ito ang ginawa ko para ma satisfy ang mga requirements. Nasa Student_Scores.txt ang code dahil di ko alam paano mag insert ng code snippet dito.

Main Menu
View attachment 1934353

Option 1
View attachment 1934354
Option 2
View attachment 1934355View attachment 1934356
Option 3
View attachment 1934358View attachment 1934359
Option 4
View attachment 1934360
C:
#include <stdio.h>
#include <stdlib.h>

#define rSize 3
#define cSize 4

void accScores(int [rSize][cSize]);

void Menu(int [rSize][cSize]);
void disp_allScore(int [rSize][cSize]);
int pick_student(); //Pick which of the student
void disp_specScore(int [rSize][cSize], int); //Display Specific Student's score
void disp_specAvgScore(int [rSize][cSize], int); //Display Specific Student's Average Score
void disp_quizStat(int [rSize][cSize]); //Display Quiz Statistics

void accScores(int scores[rSize][cSize]){
    int row, col;
   
    for(row = 0; row < rSize; row++)
    {
        printf("\nStudent %d:\n", row+1);
       
        for(col = 0; col < cSize; col++)
        {
            printf("Quiz %d: ", col+1);
            scanf("%d", &scores[row][col]);
        }
    }
}

int main(){
    int scores[rSize][cSize];
    int type;
   
   
   
    printf("Input the scores of 3 students in the 4 quizzes;");
    accScores(scores);
   
   
    Menu(scores);
   
    return 0;
}

void Menu(int scores[rSize][cSize])
{
    system("cls");
    int x;
    do
    {
        printf("==================\n");
        printf("[1] Display All Scores\n");
        printf("[2] Display Scores of a specific student\n");
        printf("[3] Display Average Score of a specific student\n");
        printf("[4] Display Quiz Statistics\n");
        printf("[0] exit\n");
        printf("==================\n");
        printf("Your choice ==> ");
        scanf("%d", &x);
        system("cls");
    }while(x<0 || x>4);
   
    switch(x)
    {
        case 0:
        {
            break;
        }
        case 1:
        {
            disp_allScore(scores);
            Menu(scores);
            break;
        }
        case 2:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 3:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specAvgScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 4:
        {
            disp_quizStat(scores);
            Menu(scores);
            break;
        }
    }
}

void disp_quizStat(int scores[rSize][cSize])
{
    int i, j;
    float total_avg = 0;
    printf("Quiz Statistics\n");
    printf("===============================================\n");
    printf("Quiz\t\tAverage\tHighest\tLowest");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        float avg = 0;
        int high, low;
        high = low = scores[0][i];
        for(j=0; j<rSize; j++)
        {
            int temp = scores[j][i];
            avg += temp;
            if(temp > high)
            {
                high = temp;
            }
           
            if(temp < low)
            {
                low = temp;
            }
        }
        total_avg += avg/4;
        printf("\nNo. %d\t\t%.2f\t%d\t%d\n", i+1, avg/4, high, low);
    }
    printf("\nTotal Quiz Average Score: %.2f\n", total_avg/4);
    printf("\n===============================================\n");
    getwchar();
    getchar();
}

void disp_specAvgScore(int scores[rSize][cSize], int x)
{
    int i;
    float avg = 0;
    printf("Student Average Score");
    printf("\n===============================================\n");
    printf("Student\t\tAverage Score");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        avg += scores[x-1][i];
    }
    printf("\nNo. %d\t\t%.2f", x, avg/4);
    printf("\n===============================================\n");
    getchar();
    getchar();
   
}

void disp_allScore(int scores[rSize][cSize])
{
    int i, j;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4");
    printf("\n===============================================");
    for(i=0; i<rSize; i++)
    {
        printf("\nNo. %d\t", i+1);
        for(j=0; j<cSize; j++)
        {
            printf("\t%d", scores[i][j]);
        }
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

void disp_specScore(int scores[rSize][cSize], int x)
{
    int i;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4\n");
    printf("===============================================\n");
    printf("No. %d\t", x);
    for(i=0; i<cSize; i++)
    {
        printf("\t%d", scores[x-1][i]);
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

int pick_student()
{
    int x;
    do
    {
        printf("Choose which student's score to display.\n");
        printf("=========================================\n");
        printf("[1] Student 1\n");
        printf("[2] Student 2\n");
        printf("[3] Student 3\n");
        printf("[0] Exit\n");
        printf("=========================================\n");
        scanf("%d", &x);
    }while(x<0 || x>3);
   
    return x;
}
Thank you po
 
Ito ang ginawa ko para ma satisfy ang mga requirements. Nasa Student_Scores.txt ang code dahil di ko alam paano mag insert ng code snippet dito.

Main Menu
View attachment 1934353

Option 1
View attachment 1934354
Option 2
View attachment 1934355View attachment 1934356
Option 3
View attachment 1934358View attachment 1934359
Option 4
View attachment 1934360
C:
#include <stdio.h>
#include <stdlib.h>

#define rSize 3
#define cSize 4

void accScores(int [rSize][cSize]);

void Menu(int [rSize][cSize]);
void disp_allScore(int [rSize][cSize]);
int pick_student(); //Pick which of the student
void disp_specScore(int [rSize][cSize], int); //Display Specific Student's score
void disp_specAvgScore(int [rSize][cSize], int); //Display Specific Student's Average Score
void disp_quizStat(int [rSize][cSize]); //Display Quiz Statistics

void accScores(int scores[rSize][cSize]){
    int row, col;
   
    for(row = 0; row < rSize; row++)
    {
        printf("\nStudent %d:\n", row+1);
       
        for(col = 0; col < cSize; col++)
        {
            printf("Quiz %d: ", col+1);
            scanf("%d", &scores[row][col]);
        }
    }
}

int main(){
    int scores[rSize][cSize];
    int type;
   
   
   
    printf("Input the scores of 3 students in the 4 quizzes;");
    accScores(scores);
   
   
    Menu(scores);
   
    return 0;
}

void Menu(int scores[rSize][cSize])
{
    system("cls");
    int x;
    do
    {
        printf("==================\n");
        printf("[1] Display All Scores\n");
        printf("[2] Display Scores of a specific student\n");
        printf("[3] Display Average Score of a specific student\n");
        printf("[4] Display Quiz Statistics\n");
        printf("[0] exit\n");
        printf("==================\n");
        printf("Your choice ==> ");
        scanf("%d", &x);
        system("cls");
    }while(x<0 || x>4);
   
    switch(x)
    {
        case 0:
        {
            break;
        }
        case 1:
        {
            disp_allScore(scores);
            Menu(scores);
            break;
        }
        case 2:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 3:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specAvgScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 4:
        {
            disp_quizStat(scores);
            Menu(scores);
            break;
        }
    }
}

void disp_quizStat(int scores[rSize][cSize])
{
    int i, j;
    float total_avg = 0;
    printf("Quiz Statistics\n");
    printf("===============================================\n");
    printf("Quiz\t\tAverage\tHighest\tLowest");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        float avg = 0;
        int high, low;
        high = low = scores[0][i];
        for(j=0; j<rSize; j++)
        {
            int temp = scores[j][i];
            avg += temp;
            if(temp > high)
            {
                high = temp;
            }
           
            if(temp < low)
            {
                low = temp;
            }
        }
        total_avg += avg/4;
        printf("\nNo. %d\t\t%.2f\t%d\t%d\n", i+1, avg/4, high, low);
    }
    printf("\nTotal Quiz Average Score: %.2f\n", total_avg/4);
    printf("\n===============================================\n");
    getwchar();
    getchar();
}

void disp_specAvgScore(int scores[rSize][cSize], int x)
{
    int i;
    float avg = 0;
    printf("Student Average Score");
    printf("\n===============================================\n");
    printf("Student\t\tAverage Score");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        avg += scores[x-1][i];
    }
    printf("\nNo. %d\t\t%.2f", x, avg/4);
    printf("\n===============================================\n");
    getchar();
    getchar();
   
}

void disp_allScore(int scores[rSize][cSize])
{
    int i, j;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4");
    printf("\n===============================================");
    for(i=0; i<rSize; i++)
    {
        printf("\nNo. %d\t", i+1);
        for(j=0; j<cSize; j++)
        {
            printf("\t%d", scores[i][j]);
        }
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

void disp_specScore(int scores[rSize][cSize], int x)
{
    int i;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4\n");
    printf("===============================================\n");
    printf("No. %d\t", x);
    for(i=0; i<cSize; i++)
    {
        printf("\t%d", scores[x-1][i]);
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

int pick_student()
{
    int x;
    do
    {
        printf("Choose which student's score to display.\n");
        printf("=========================================\n");
        printf("[1] Student 1\n");
        printf("[2] Student 2\n");
        printf("[3] Student 3\n");
        printf("[0] Exit\n");
        printf("=========================================\n");
        scanf("%d", &x);
    }while(x<0 || x>3);
   
    return x;
}
nag papacomission po ba kayo?
 
nag papacomission po ba kayo?
C to paps?

C to paps? Lakas ako kasi nalilito e
Ito ang ginawa ko para ma satisfy ang mga requirements. Nasa Student_Scores.txt ang code dahil di ko alam paano mag insert ng code snippet dito.

Main Menu
View attachment 1934353

Option 1
View attachment 1934354
Option 2
View attachment 1934355View attachment 1934356
Option 3
View attachment 1934358View attachment 1934359
Option 4
View attachment 1934360
C:
#include <stdio.h>
#include <stdlib.h>

#define rSize 3
#define cSize 4

void accScores(int [rSize][cSize]);

void Menu(int [rSize][cSize]);
void disp_allScore(int [rSize][cSize]);
int pick_student(); //Pick which of the student
void disp_specScore(int [rSize][cSize], int); //Display Specific Student's score
void disp_specAvgScore(int [rSize][cSize], int); //Display Specific Student's Average Score
void disp_quizStat(int [rSize][cSize]); //Display Quiz Statistics

void accScores(int scores[rSize][cSize]){
    int row, col;
   
    for(row = 0; row < rSize; row++)
    {
        printf("\nStudent %d:\n", row+1);
       
        for(col = 0; col < cSize; col++)
        {
            printf("Quiz %d: ", col+1);
            scanf("%d", &scores[row][col]);
        }
    }
}

int main(){
    int scores[rSize][cSize];
    int type;
   
   
   
    printf("Input the scores of 3 students in the 4 quizzes;");
    accScores(scores);
   
   
    Menu(scores);
   
    return 0;
}

void Menu(int scores[rSize][cSize])
{
    system("cls");
    int x;
    do
    {
        printf("==================\n");
        printf("[1] Display All Scores\n");
        printf("[2] Display Scores of a specific student\n");
        printf("[3] Display Average Score of a specific student\n");
        printf("[4] Display Quiz Statistics\n");
        printf("[0] exit\n");
        printf("==================\n");
        printf("Your choice ==> ");
        scanf("%d", &x);
        system("cls");
    }while(x<0 || x>4);
   
    switch(x)
    {
        case 0:
        {
            break;
        }
        case 1:
        {
            disp_allScore(scores);
            Menu(scores);
            break;
        }
        case 2:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 3:
        {
            int c = pick_student();
            system("cls");
            if(c > 0)
            {
                disp_specAvgScore(scores, c);
            }
            Menu(scores);
            break;
        }
        case 4:
        {
            disp_quizStat(scores);
            Menu(scores);
            break;
        }
    }
}

void disp_quizStat(int scores[rSize][cSize])
{
    int i, j;
    float total_avg = 0;
    printf("Quiz Statistics\n");
    printf("===============================================\n");
    printf("Quiz\t\tAverage\tHighest\tLowest");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        float avg = 0;
        int high, low;
        high = low = scores[0][i];
        for(j=0; j<rSize; j++)
        {
            int temp = scores[j][i];
            avg += temp;
            if(temp > high)
            {
                high = temp;
            }
           
            if(temp < low)
            {
                low = temp;
            }
        }
        total_avg += avg/4;
        printf("\nNo. %d\t\t%.2f\t%d\t%d\n", i+1, avg/4, high, low);
    }
    printf("\nTotal Quiz Average Score: %.2f\n", total_avg/4);
    printf("\n===============================================\n");
    getwchar();
    getchar();
}

void disp_specAvgScore(int scores[rSize][cSize], int x)
{
    int i;
    float avg = 0;
    printf("Student Average Score");
    printf("\n===============================================\n");
    printf("Student\t\tAverage Score");
    printf("\n===============================================");
    for(i=0; i<cSize; i++)
    {
        avg += scores[x-1][i];
    }
    printf("\nNo. %d\t\t%.2f", x, avg/4);
    printf("\n===============================================\n");
    getchar();
    getchar();
   
}

void disp_allScore(int scores[rSize][cSize])
{
    int i, j;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4");
    printf("\n===============================================");
    for(i=0; i<rSize; i++)
    {
        printf("\nNo. %d\t", i+1);
        for(j=0; j<cSize; j++)
        {
            printf("\t%d", scores[i][j]);
        }
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

void disp_specScore(int scores[rSize][cSize], int x)
{
    int i;
    printf("Student Quiz Record");
    printf("\n===============================================\n");
    printf("Student\t\tQuiz 1\tQuiz 2\tQuiz 3\tQuiz 4\n");
    printf("===============================================\n");
    printf("No. %d\t", x);
    for(i=0; i<cSize; i++)
    {
        printf("\t%d", scores[x-1][i]);
    }
    printf("\n===============================================\n");
    getchar();
    getchar();
}

int pick_student()
{
    int x;
    do
    {
        printf("Choose which student's score to display.\n");
        printf("=========================================\n");
        printf("[1] Student 1\n");
        printf("[2] Student 2\n");
        printf("[3] Student 3\n");
        printf("[0] Exit\n");
        printf("=========================================\n");
        scanf("%d", &x);
    }while(x<0 || x>3);
   
    return x;
}
 

Similar threads

Back
Top