Question

In: Computer Science

You are using ONLY Programming Language C for this: In this program you will calculate the...

You are using ONLY Programming Language C for this:

In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out:

1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array.

2. Use the function to scan the grades of the array. To say another way, we will populate the array with a function.

3. When done, you are going to use a printing function to make sure all grades are scanned correctly.

4. After that, you will call the “average” function. This function will receive two parameters: the array’s length and the array. Inside that function, you will calculate the average (use a loop for this) and you will return the average.

5. In main, you will have received this returned value and print it (IMPORTANT).

Solutions

Expert Solution

This Solution is for only 1 student, Although I have created the test cases so you go any number of test cases. 

#include<stdio.h>
void main()
{
    int t; //For Test Cases
    scanf("%d",&t);
    while(t--)
    {
        int mark[5], i; //Creating Marks in array
        float sum=0,avg; 
        printf("Enter marks obtained in 5 subjects :");
        for(i=0; i<5; i++) //Using Loop to enter marks
        {
                scanf("%d",&mark[i]);
                sum=sum+mark[i];
        }
        avg=sum/5; //Average Formula
        printf("Your Grade is "); //Assuming Grades for students
        if(avg>80)
        {
                printf("A");
        }
        else if(avg>60 && avg<=80)
        {
                printf("B");
        }
        else if(avg>40 && avg<=60)
        {
                printf("C");
        }
        else
        {
                printf("D");
        }
    }

}

Related Solutions

Only Program in C for this. No other programming language is allowed. Using a function, we...
Only Program in C for this. No other programming language is allowed. Using a function, we will add a range of values of an array. The range is going to be determined by the user. In this example, if you put the following array down as: 1.5 -5.6 8.9 4.6 7.8 995.1 45.1 -5964.2 … and the user tells you to add from the 3rd element to the 6th element, your program is going to need to add the values:...
Write a program that performs a merge-sort algorithm without using a recursion. c++ programming language(Only #inlclude...
Write a program that performs a merge-sort algorithm without using a recursion. c++ programming language(Only #inlclude <iostream>)
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library and dynamic memory(malloc) that multiplies two matrices together. The numbers in the matrices must be read in from a text file. The program should also check if the two matrices are capable of being multiplied together. The amount of threads used has to be dynamic. The user should be able to choose how many threads they wish to use using the command line. Finally,...
Programming Language C++ Task 1: Write a program to calculate the volume of various containers. A...
Programming Language C++ Task 1: Write a program to calculate the volume of various containers. A base class, Cylinder, will be created, with its derived classes, also called child classes or sub-classes. First, create a parent class, Cylinder. Create a constant for pi since you will need this for any non-square containers. Use protected for the members. Finally, create a public function that sets the volume. // The formula is: V = pi * (r^2) * h Task 2: Create...
Using C# programming language, Write a program that sort three numbers entered by the user using...
Using C# programming language, Write a program that sort three numbers entered by the user using only if and nested if statements. If for instance the user entered 5, 2, and 7; the program should display 2,5,7.
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
Using the C Programming language, write a program that sums an array of 50 elements. Next,...
Using the C Programming language, write a program that sums an array of 50 elements. Next, optimize the code using loop unrolling. Loop unrolling is a program transformation that reduces the number of iterations for a loop by increasing the number of elements computed on each iteration. Generate a graph of performance improvement. Tip: Figure 5.17 in the textbook provides an example of a graph depicting performance improvements associated with loop unrolling. Marking:- Optimize the code for an array of...
Using c# programming language Write a program that mimics a lottery game. Have the user enter...
Using c# programming language Write a program that mimics a lottery game. Have the user enter 3 distinct numbers between 1 and 10 and match them with 3 distinct, randomly generated numbers between 1 and 10. If all the numbers match, then the user will earn $10, if 2 matches are recorded then the user will win $3, else the user will lose $5. Keep tab of the user earnings for, let say 5 rounds. The user will start with...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
C Programming Language: For this lab, you are going to create two programs. The first program...
C Programming Language: For this lab, you are going to create two programs. The first program (named AsciiToBinary) will read data from an ASCII file and save the data to a new file in a binary format. The second program (named BinaryToAscii) will read data from a binary file and save the data to a new file in ASCII format. Specifications: Both programs will obtain the filenames to be read and written from command line parameters. For example: - bash$...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT