Answer to Question #338522 in C for hanan

Question #338522

a) Write a C program that reads marks of 10 students in to a single subscripted array. b) Above marks should be between 0 to 20. Modify the above program to add marks to the array only if the input mark is between the given range. c) Display the values stored in the array


1
Expert's answer
2022-05-08T14:32:54-0400
#include <stdio.h>


int main()
{
    int marks[10];
    int temp=0;
    int low=0;
    int hight=0;
    for(unsigned int i=0; i<sizeof(marks)/sizeof(int); i++)
        marks[i]=-1;
    scanf("%i %i",&low,&hight);
    for(unsigned int i=0; i<sizeof(marks)/sizeof(int); i++) {
        scanf("%i",&temp);
        if (temp>=low && temp<=hight && temp>=0 && temp<=20) //b part.
            marks[i]=temp;
    }
    for(unsigned int i=0; i<sizeof(marks)/sizeof(int); i++) //c part.
        if(marks[i]!=-1) printf("out:%i\n",marks[i]);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS