Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have asked this question before, but the code I was given does not continue reading the rest of the numbers after the negative number

I have asked this question before, but the code I was given does not continue reading the rest of the numbers after the negative number is entered. If the user enters the negative number as the 3rd number, I don't want the loop to stop there before they get to enter all 50 numbers. After they have entered all 50 numbers including the negative number, I want to then display the numbers they've entered prior to the negative number. to the output file.

Here is the code in C++

#include using namespace std; void read_data_function(); void display_numbers(); void display_all_numbers(); int stack[50],top=-1,i; void read_data_function() { for(i=0;i<50;i++) { top++; cin>>stack[i]; if(stack[i]<0) { break; } } } void display_numbers() { cout<<" "; cout<<"displaying all numbers you entered prior to negative number"<<" "; for(i=0;i

cout<=0) { cout<

read_data_function(); display_numbers(); display_all_numbers(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions