logo

C Programming: Stack Implementation and Score Analysis

   

Added on  2020-05-16

11 Pages1305 Words31 Views
 | 
 | 
 | 
Data StructureName of the student:Name of the University:Author note:
C Programming: Stack Implementation and Score Analysis_1

Table of ContentsQuestion 1 Scores Program.............................................................................................................3Source Code.................................................................................................................................3Output Screenshot........................................................................................................................8Question 2 Stack Program...............................................................................................................9Source code..................................................................................................................................9Output Screenshot......................................................................................................................11
C Programming: Stack Implementation and Score Analysis_2

Question 1 Scores ProgramProblem StatementWrite a complete C program which uses an array application. The program will inputmid-semester test scores which are kept in a Main Scores Array. Valid test scores ranges from 0to 100. Invalid test scores are below 0 and above 100, which is out of the valid score range. Anerror message is displayed when an invalid test score is entered. The valid test scores are kept ina Valid Scores Array, and the invalid test scores are kept in a Invalid Scores Array. The program will produce six outputs:1.Valid scores.2.Invalid scores. 3.The average, lowest and highest of the valid scores.4.A histogram, giving for each valid score a bar whose length is proportional to the numberachieving that score.The total number of invalid scores.Source Code#include<stdio.h>#define size 100 //define array max size//histogram function creates the histogram by comparing data against the range in argumentsvoid histogram(int arr[size], int valSize, int lRange, int uRange){printf(" [%d - %d]:\t",lRange,uRange);
C Programming: Stack Implementation and Score Analysis_3

int i;for(i=0;i<valSize;i++){if(arr[i]>=lRange && arr[i]<=uRange)printf("x");}printf("\n");}//function mainvoid main(){int i,n, invalCount=0, valCount=0, max ,min;float sum=0.0, avg;int mainScores[size], validScores[size], invalidScores[size];while(1){printf("How many marks to enter (from 1 to %d)?? .. ",size);scanf("%d",&n);if(n>size || n<1) //check if user enters a valid limit{printf("Wrong entry!!\n"); }else{break;}}for(i=0;i<n;i++){
C Programming: Stack Implementation and Score Analysis_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents