Question

Write a program that asks the user to input 5 integers in an Array named gradearray.” then passes gradearray in a function t

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

#source code in c++:

#include <iostream>

using namespace std;

int gradearrayfun(int gradearray[]){

int pass=0;

for(int i=0;i<5;i++){

if(gradearray[i]>=60 && gradearray[i]<=100){

pass=pass+1;

}

}

return pass;

}

int main(){

int gradearray[5];

for(int i=0;i<5;i++){

cin>>gradearray[i];

}int pass=0,fail=0;

pass=gradearrayfun(gradearray);

fail=5-pass;

cout<<"There are "<<pass<<" passing grades"<<endl;

cout<<"There are "<<fail<<" failing grades"<<endl;

return 0;

}

#include <iostream> using namespace std; int gradearrayfun(int gradearray[]) { int pass=0; for(int i=0;i<5;i++) { if(gradearr

user@user-Latitude - 3490:-/Desktop$ g++ 1.cpp user@user-Latitude - 3490:-/Desktop$ ./a.out 67 43 90 100 75 There are 4 passi

#source code in c:

#include <stdio.h>

int gradearrayfun(int gradearray[]){

int pass=0;

for(int i=0;i<5;i++){

if(gradearray[i]>=60 && gradearray[i]<=100){

pass=pass+1;

}

}

return pass;

}

int main(){

int gradearray[5];

for(int i=0;i<5;i++){

scanf("%d",&gradearray[i]);

}int pass=0,fail=0;

pass=gradearrayfun(gradearray);

fail=5-pass;

printf("There are %d passing grades\n",pass);

printf("There are %d failing grades\n",fail);

return 0;

}

#include <stdio.h> int gradearrayfun (int gradearray[]) { int pass=0; for(int i=0;i<5;i++) { if(gradearray[i]>=60 && gradearr

#output:

user@user-Latitude - 3490:-/Desktops gcc 1.C -0 samp user@user-Latitude - 3490:-/Desktop$ ./samp 67 43 90 100 75 There are 4

Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user to input 5 integers in an Array named "gradearray.”...
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
  • Write a program that asks the user to input 10 integers of an array. The program...

    Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...

  • Write a program that asks the user to enter 1000 integers to be stored in an...

    Write a program that asks the user to enter 1000 integers to be stored in an array called "numbers". Since the same integer might occur (exist) in the array multiple times, your program needs to fill a second array, called "Isolate" that contains all the integers from the first array but NOT REPAPTED (every integer will exist only once). Finally, your program will print the integers of the second array sorted by occurrence (occurrence is: the number of times the...

  • This code should be written in php. Write a program that allows the user to input...

    This code should be written in php. Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography. When the user submits this information, store it in an associative array, like this: Smith=61 67 75 80 72 where the key is the student's last name, and the grades are combined into a single space-delimited string. Return the user back to the data entry screen, to allow...

  • Write a program that first gets a list of integers from the input and adds them...

    Write a program that first gets a list of integers from the input and adds them to an array. The input begins with an integer indicating the number of integers that follow (Your program should work for any size of the array). Then, get the last value from the input, and output all integers less than or equal to that value by iterating through the array. Ex: If the input is: Enter the number of integers: 5 Enter integer 1:...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • Write a program that asks the user for a student name and asks for grades until...

    Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...

  • Write a program that reads a sequence of integers into an array and that computes the...

    Write a program that reads a sequence of integers into an array and that computes the alternating sum of all elements in the array. For example, if the program is executed with the input data: 2 1 4 9 16 9 7 4 9 11 Then it computes 2 - 1 + 4 - 9 + 16 - 9 + 7 - 4 + 9 – 11 = 4 Use a scanner object to gather the inputs from the user....

  • Write a function to have a user enter some number of integers into an array. The...

    Write a function to have a user enter some number of integers into an array. The integer values must be between -100 and +100 inclusive (+100 and -100 should be accepted as valid inputs). The integer array and the size of the array are passed into the function through parameters. Do not worry about includes. This is only a function, so there is no main routine. The function should fill the array with valid inputs. For invalid input values, inform...

  • Write a c program to implement threads. Accept an array of 40 integers, write a thread...

    Write a c program to implement threads. Accept an array of 40 integers, write a thread method named sum of array elements. Divide the array into 4 equal elements and call threads to find the sum of each part. Store the sum in a variable called “arrays'. Print the sum in the main function. (10 points)

  • IN JAVA Write a program that first gets a list of integers from input. The input...

    IN JAVA Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75...

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