1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lesantik [10]
3 years ago
9

Write a program that continually prompts the user for an integer input until input is entered that is less than 0. Each input th

at is accepted is appended to an array named inputs, until an invalid input is given. When the first invalid input is entered the program prints the array and exists.
Computers and Technology
1 answer:
professor190 [17]3 years ago
7 0

Answer:

Following are the program in the C++ Programming Language:

#include <iostream>//header file

using namespace std;//namespane

//set main method

int main() {  

int a[100]; //set integer type array variable

int value, i = 0; //set integer variables

cout<<"Enter less than 0 to exit:"<<endl; //message for exit

cout<<"Enter the integer numbers:"<<endl; //message to enter numbers

do{ //set do while

cin>>value; //get input from the user

a[i++] = value; //append elements in array

}while(value>=0);

i--;  

cout<<"\nArray are:"<<endl;//message for array

for(int k = 0;k<i;k++){ //set for loop

cout<<a[k]<<" "; //print array

}

return 0;

}

<u>Output</u>:

Enter less than 0 to exit:

Enter the integer numbers:

1

2

3

4

5

-1

Array are:

1 2 3 4 5

Explanation:

Here, we set the integer data type main method "main()" and inside it:

  • we set integer type array variable with index value 100.
  • we set two integer type variable "value" and "i" initialize value 0.
  • we set the do-while loop in which we get the input from the user and and append in the array and pass condition if the value is greater then equal to 0.
  • Finally, set for loop and print the elements of an array.

 

You might be interested in
Prompt the user for an automobile service. Each service type is composed of two strings. Output the user's input. (1 pt) Ex: Ent
Svet_ta [14]

Answer:

Required code is given below.

Best Regards,

Please ask if any queries.

Explanation:

#include <stdio.h>

#include <string.h>

int main(void)

{

  char input[100];

  printf("Enter desired auto service:\n");

  scanf ("%[^\n]%*c", input);

  printf("You entered: %s\n",input);

  if(strcmp(input,"Oil change") == 0){

     printf("Cost of oil change: $35\n");

  }

  else if(strcmp(input,"Tire rotation") == 0){

     printf("Cost of tire rotation: $19\n");

  }

  else if(strcmp(input,"Car wash") == 0){

     printf("Cost of car wash: $7\n");

  }

  else{

      printf("Error: Requested service is not recognized\n");

  }

   

  return 0;

}

8 0
3 years ago
I'm not sure how to do these. By the way, it has to be python.
frutty [35]

Task 1:

float75 = float(75)

string75 = "75"

# you cannot add together a number and a string because a string has no inherent numerical value like a number does.

Task 2:

num = float(input("Enter a number"))

print(num**2)

Task 3:

num = int(input("Enter an integer: "))

print("When you divide "+str(num)+" by 7, the quotient is "+str(num//7)+" and the remainder is "+str(num%7)+".")

Task 4:

gigs = int(input("How many gigabytes does your flashdrive hold? "))

print("A flashdrive with "+str(gigs)+ " gigabyte(s) holds "+str(gigs*8589934592)+" bit(s).")

For task 4, you might have to change the number 8589934592 to something else. I'm not entirely sure how many bits are in a gigabyte. I hope this helps though.

6 0
2 years ago
Write a function named shareALetter that takes one parameter, wordList – a list of words. Create and return a dictionary in whic
Arte-miy333 [17]
Can u send anything to understand it
7 0
3 years ago
If you see these REPORT.
Alenkinab [10]

Answer:

ok will do

Explanation:

3 0
2 years ago
Read 2 more answers
Write a python program that prints the multiplication table of 9 ?​
ololo11 [35]
X = int(input(“Enter a number”))
table = x * 9
print table

#For the number inputed it will output that number multiplied by 9
7 0
2 years ago
Read 2 more answers
Other questions:
  • Which graphic design tool allows you to lay images on top of one another? A. Layers B. Selection C. Drawing D. Color
    10·2 answers
  • 2. You have classes to represent different shapes (see below). You realize you can benefit from inheritance and polymorphism by
    13·1 answer
  • Data is: a. Information endowed with relevance and purpose b. Set of specific objective facts or observations c. Some informatio
    10·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    5·1 answer
  • When Web users enter the URL www.CIWcertified.com in their browser address bar, they can access the official CIW Web site at the
    6·2 answers
  • What happens to a data table when the formulas or variables used to create it are changed?
    9·2 answers
  • Which descriptions offer examples of Correction Services workers? Select all that apply.
    8·1 answer
  • Explain how to utilize the computer in rooms management.​
    13·1 answer
  • How does your ability to correctly count change affect the impression the customer has of you?
    8·1 answer
  • Which era marked a switch from agricultural practices to industrial practices?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!