Question

lings Review View No Spacing) しHeading 1 CNIT105- INLAB08 Due: By the end of the lab session Objectives: Parallel Arrays Sequential Search Named Constant: Define a named constant, SIZE-20 for size of array Write the code in the main function to do the following tasks 1. Declare an array to store up to 20 scores- whole numbers 2. Partially fill the arrays in a loop- use score -1 to end the data entry 3. Display the number of entries in the array 4. Write a loop to display array score to the screen. 5. Compute the average score - display it to the screen. 6. Use sequential search to display all the scores 70. a. Inform the user if search fails. 7, Use sequential search to find the unique score 100. a. Inform the user if search fails.
media%2F5c4%2F5c4a5cdc-4f08-4a05-8dbe-75
0 0
Add a comment Improve this question Transcribed image text
Answer #1

you didnt specify the language so I am doing it using c. if you want it in other language comment I will upload it in that language.

<-----------------------------------------------------marks.c------------------------------------------------------------------------------------------>

#include<stdio.h>

//declaring constant int SIZE =20

const int SIZE = 20;

int main(){

//declaring require variables

int marks[SIZE]; //marks array

int data; //data to take input from user and assign it to marks[SIZE] ARRAY

int i; //iterative variable

int no_of_entries=0;//variable for countint total entries into array

int sum = 0; //variable to track the sum of all elements in the array

float average; //float for calculating average value

//using loop to take input from user

for(i = 0;i<SIZE;i++){

printf("Enter Student's Score : ");

scanf("%d",&data);

marks[i]=data;

//checking data weather it is -1 or not using if condition

if(data==-1){

//breaking the loop if enter data is -1

break;

}

//calculating sum at the time of input

sum = sum + data;

//incrementing no of entries

no_of_entries++;

}

//printing no of entries

printf("\nNo of Entries = %d\n",no_of_entries);

//loop for printing scores

printf(" Score\n *****************************\n");

for(i=0;i<no_of_entries;i++){

printf(" %d\n",marks[i]);

}

//calculating average and printing average upto 2 values after decimal

average = (float)sum/(float)no_of_entries;

printf("\n The average score is %0.2f\n",average);

//printing scores greater than or equal to 70 using sequential search

printf("\n Scores >= 70 are : \n");

for(i=0;i<no_of_entries;i++){

if(marks[i]>= 70)

printf(" %d\n",marks[i]);

}

//finding 100 score using seqential search

int score_found_flag = 0;

for(i=0;i<no_of_entries;i++){

if(marks[i]==100){

printf("\n Student with score=100 was found\n");

score_found_flag = 1;

break;

}

}

//if we did find 100 the if condition will execute

if(!score_found_flag){

printf("\n Student with score=100 was not found\n");

}

}

outputs:-

same input as shown in the question image

Dev-C++5.2.0.2 Eile Edit Search iew Project Eyecute Debug Iools CVS Window Help global:) Project Classes Debug marks.d 38 CAP

output without entering 100:-

Dev-C++5.2.0.2 File Edit Search 囗図| E{ € | C:\Program Files (x86NDev-CppiConsolepauser.exe nter Students Score nter Student

Add a comment
Know the answer?
Add Answer to:
lings Review View No Spacing) しHeading 1 CNIT105- INLAB08 Due: By the end of the lab...
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
  • CNIT 105 In Lab10 Due: By the end of your lab session OBJECTIVES: bitwise operations main...

    CNIT 105 In Lab10 Due: By the end of your lab session OBJECTIVES: bitwise operations main () function: 1. Declare an int variable, name it number. 2. Prompt the user to enter a whole number- read it into the variable. Validate the range in a loop. Valid range is 20 to 200 both inclusive . 3. Display the number to the screen (base 10) 4, Display the number in hexadecimal (Use %X) 5. Display number to the screen -It will...

  • Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the...

    Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the original high score program,: Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look exactly like this: Enter the name for score #1: Suzy Enter the score for...

  • C++ Programming

    PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...

  • The purpose of this assignment is to get experience with an array, do while loop and...

    The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...

  • Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that...

    Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that searches for a number in an array. T a. Write a bool function named search that receives 3 parameters: an int array, an int containing the length of the array, and an int number to search for. Return true if the number is in the array and false otherwise. b. Write a void function called fillArray with the array as a parameter that uses...

  • IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are...

    IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are developing a program that works with arrays of integers, and you find that you frequently need to duplicate the arrays. Rather than rewriting the array-duplicating code each time you need it, you decide to write a function that accepts an array and its size as arguments. Creates a new array that is a copy of the argument array, and returns a pointer to the...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • COMP1410 - Lab Exercises #3 (Due at the end of the lab period or beginning of...

    COMP1410 - Lab Exercises #3 (Due at the end of the lab period or beginning of the next) Start Date: Oct. 1st, 2019 Objectives: Practice dealing with 2D arrays. Create a two dimensional array (e.g. int A2D[M] [N] ;) of size MXN to store integer values. Use #define M 4 and N 3 to start. (Using symbolic constants instead of hard coding the array sizes improves scalability). Create an interactive menu within main() for this program (call it Lab3.c) with...

  • Lab Topics • The basics of Array object Use the following Coding Guidelines • When declaring...

    Lab Topics • The basics of Array object Use the following Coding Guidelines • When declaring a variable, you usually want to initialize it. Remember you cannot initialize a number with a string. Remember variable names are case sensitive. Use tabs or spaces to indent code within blocks (code surrounded by braces). Use white space to make your program more readable. Use comments after the ending brace of classes, methods, and blocks to identify to which block it belongs. Problem...

  • Lab Objectives Be able to write methods Be able to call methods Be able to declare...

    Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...

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