Question

C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the followi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :

1.The below code will work perfectly and it has no errors.

2.So just copy and run the code

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

int main()
{
char first_name[50],last_name[50];
int course_number,c_project_number;
int marks[8];
printf("\n\nEnter your First Name :");
scanf("%s",&first_name);
printf("\n\nEnter your Last Name :");
scanf("%s",&last_name);
printf("\n\nEnter your Course Number :");
scanf("%d",&course_number);
printf("\n\nEnter your C Project Number :");
scanf("%d",&c_project_number);
printf("\n\nEnter your Marks Subjects for Eight Subjects");

int i=0;
int input=1;

for(i=0;i<8;i++)
{
   printf("\n\nEnter Mark for Subject %d :",input);
   scanf("%d",&marks[i]);
   input++;
}

int total_marks=0;
int total_subjects=8;
for(i=0;i<8;i++)
{
    total_marks=total_marks+marks[i];
}

float average;

if(total_subjects==0)
printf("\n\nZero ivision Error!");
else
{
    average=total_marks/total_subjects;
}

printf("\n\n\n\nFirst Name : %s",first_name);
printf("\n\nLast Name : %s",last_name);
printf("\n\nCourse Number : %d",course_number);
printf("\n\nC Project Number : %d",c_project_number);

printf("\n\nAll Numbers in the Array :\n\n");
for(i=0;i<8;i++)
{
   printf("%d ",marks[i]);
}

printf("\n\nSum of all numbers in the Array : %d",total_marks);
printf("\n\nThe count of all numbers in the Array : %d",total_subjects);
printf("\n\nAverage of all numbers in the Array : %.2f",average);


}

Add a comment
Know the answer?
Add Answer to:
C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 14.8 Prog 8 Overload methods (find avg) Write a program to find the average of a...

    14.8 Prog 8 Overload methods (find avg) Write a program to find the average of a set numbers (assume that the numbers in the set is less than 20) using overload methods. The program first prompts the user to enter a character; if the character is 'I' or 'i', then invokes the appropriate methods to process integer data set; if the character is 'R' or 'r', then invokes the appropriate methods to process real number data set; if the inputted...

  • (C++ programming) Need help with homework. Write a program that can be used to gather statistical...

    (C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...

  • Kindly follow the instructions provided carefully. C programming   Project 6, Program Design One way to encrypt...

    Kindly follow the instructions provided carefully. C programming   Project 6, Program Design One way to encrypt a message is to use a date’s 6 digits to shift the letters. For example, if a date is picked as December 18, 1946, then the 6 digits are 121846. Assume the dates are in the 20th century. To encrypt a message, you will shift each letter of the message by the number of spaces indicated by the corresponding digit. For example, to encrypt...

  • Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program...

    Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • 4. Write a C program that will perform the following: a. In the main program enter...

    4. Write a C program that will perform the following: a. In the main program enter 2 integer numbers. If the first number is less than the second number call the function happy(). Otherwise give a warning message that the function is not performed. b. Define a function happy() that will request from the user to enter 10 integer numbers to one dimensional array A. The function will find and return how many numbers are above 5.

  • need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that...

    need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...

  • C Programming, part B: (1 point) Write a second program (Program B) that builds a contiguous...

    C Programming, part B: (1 point) Write a second program (Program B) that builds a contiguous list (i.e., array- based), also of 100 elements (cells), each containing a random integer between 0 and 99. You encouraged to re-use as much code from Program A as you wish (this is called code re- sue and it is a good thing). This program must: 1) Build the contiguous list (i.e., the properly populated array) 2) Print out the contents of the list....

  • Following the instruction This is c++ programming Lab Tasks: 1. Define a dynamic array class in...

    Following the instruction This is c++ programming Lab Tasks: 1. Define a dynamic array class in DynamicArray .h and DynamicArray.cpp files, according to the following UML class diagram: DynamicArray - int arrySize; - int currentSize; int* arrayPtr; + DynamicArray(int size) // Explicit constructor, which you define- allocate space in dynamic memory for an integer array of the given size. + DynamicArray) // Explicit destructor, which you define-de allocate dynamic memory. + additem(int item): bool // Set the value of the...

  • Problem: Design and write a C language program that can be used to calculate Voltage, Current...

    Problem: Design and write a C language program that can be used to calculate Voltage, Current and Total Resistance for a Series or Parallel or a Series Parallel circuit. The program should display the main menu that contains the three types of circuit calculations that are available and then the user will be prompted to select a circuit first. After the circuit has been selected the program should then display another menu (i.e., a submenu) requesting the necessary data for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT