0
1.7kviews
Write a C program to display particular output

Write a C program to display output as shown in the image below. The user must enter a student id and the output will show the marks and histrogram.

C program output

1 Answer
0
3views

Program

#include < stdio.h >

int main() {
    int n;
    printf("Enter number of entries ");
    scanf("%d", & n);

    int id[n], marks[n];
    for (int i = 1; i <= n; i++) {
        printf("\nEnter Student id and marks ");
        scanf("%d %d", & id[i], & marks[i]);
    }
    printf("\n\n");
    printf("Student id\t\t\tMarks\t\t\t\tHistogram\n");
    for (int i = 1; i <= n; i++) {

        printf("\n%d\t\t\t\t%d\t\t\t\t", id[i], marks[i]);
        for (int j = 1; j <= marks[i]; j++)
            printf("*");
    }

}

NOTE: Number of entries, Student id, and marks are entered by the user. (Question is bit incomplete)

Please log in to add an answer.