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
Sloan [31]
3 years ago
3

Write a complete program that reads 6 numbers and assigns True to variable isAscending if the numbers are in ascending order. Ot

herwise assign False to it. Display the value of isAscending. Here are three sample runs: Sample Run 1 Enter six numbers: 4 6 8 10 11 12 True Sample Run 2 Enter six numbers: 4 6 3 10 11 12 False Sample Run 3 Enter six numbers: 41 6 3 10 11 12 False Note: Your program must match the sample run exactly.
Computers and Technology
1 answer:
kolbaska11 [484]3 years ago
3 0

Answer:

<em>The programming language is not stated;</em>

<em>For this, I'll answer your question using c++ programming language</em>

<em>The program does not make use of comments (See explanation for further details)</em>

<em>From the sample run, the input numbers are integer; So, this program assumes that all input will be integer...</em>

<em>Program starts here</em>

#include<iostream>

using namespace std;

int main()

{

cout<<"Enter six numbers: ";

int Arr[6];

for(int i = 0;i<6;i++)

{

 cin>>Arr[i];

}

bool flag = true;

for(int i = 0;i<6;i++)  

{

for(int j = i;j<6;j++)

{

 if(Arr[i]>Arr[j])

 {

  flag = false;

 }

}

}

string isAscending;

if(flag)

{

isAscending = "True";

}

else

{

isAscending = "False";

}

 

cout<<isAscending;

return 0;

}

Explanation:

cout<<"Enter six numbers: ";  -> This line prompts the user for input

int Arr[6]; -> The input is stored in an array; This line declares the array

The following for loop iteration is used to iterate through the array

for(int i = 0;i<6;i++)

{

 cin>>Arr[i];  -> This line accepts user input

}

bool flag = true;  -> A boolean variable is initialized to true

The following nested loop checks if numbers are in ascending order

for(int i = 0;i<6;i++)  

{

for(int j = i;j<6;j++)

{

 if(Arr[i]>Arr[j])  -> This particular if statement checks if a number is greater than the next number

 {

  flag = false;  -> If yes, the boolean variable is changed to false

 }

}

}  - > The nested loop ends here

string isAscending  = "True";  -> Here, isAscending is declared as string

if(flag)  If boolean variable flag is true; i

{

isAscending = "True";  "True" is assigned to isAscending

}

else  -> Otherwise; if boolean variable flag is no longer true; i.e if it's false

{

isAscending = "False"; -> "False" is assigned to isAscending

}

cout<<isAscending;  -> The corresponding value of isAscending is printed

You might be interested in
Take any software or Application that you have recently purchased, this can be a video game or any other application helping you
IgorC [24]

A good product should have copyright protection which prevents others from using the product without permission.

Some products specify the penalties which are given to a person who makes unauthorized copies of their product and this is done to clearly educate to avoid ignorance claims.

A good product should have clear lettering which are legible and can be easily read, and should also have reasonable copyright protection.

<h3>What is Copyright?</h3>

This refers to the licensing which is done for a product and is also legally backed which prevents a person from illegally using or redistributing the work of a creator without their explicit consent.

Read more about copyright infringement here:
brainly.com/question/1078532

8 0
2 years ago
Question 3 (2 points)
jeyben [28]

Answer:

The energy source that does not use heat in the process of converting it to electricity is;

c. Sunlight

Explanation:

In converting Sunlight energy source to electricity, the photons in the light from the Sun excite electrons in the solar cells silicon layers, such that the electrons travel from n-type silicon layer to the p-type silicon layer creating electric potential energy that does work as the electrons flow back in the form of electricity from the p-type to the n-type silicon layer through an external circuit

7 0
3 years ago
Photographing during the midday can produce which of the following?
deff fn [24]
It can produce harsh shadows
5 0
3 years ago
Read 2 more answers
The input nums is supposed to be an array of unique integers ranging from 1 to nums.length (inclusive). However, there is a mist
Elden [556K]

The program is an illustration of loops.

Loops are used to perform repetitive and iterative operations.

The program in Python where comments are used to explain each line is as follows:

#This intializes the list

nums = [5,4,4,2,1]

#This gets the length of the list

size = len(nums)

#This iterates through the list

for i in range(size):

   #The following if condition determines the repeating number

   if nums[abs(nums[i])-1] > 0:

       nums[abs(nums[i])-1] = -nums[abs(nums[i])-1]

   else:

       repeating = abs(nums[i])

   #The following if condition determines the missing number

   if nums[i]>0:

       missing = i + 1

   

#This calculates and prints the sum of the missing and the repeating numbers

print(repeating+missing)

Read more about similar programs at:

brainly.com/question/13549861

6 0
3 years ago
When the degree of color contrast between items is low, the content is easier to see and read. True or False
Alexus [3.1K]

the answer is false

hope that helps

3 0
3 years ago
Other questions:
  • What type of lights are necessary for silhouettes?
    12·2 answers
  • Vaporization is the process in which liquid is sufficiently cooled to change states of matter from a liquid to a vapor true or f
    8·1 answer
  • In a paragraph of no less than 125 words, describe how technology helps business professionals to be more efficient. Include exa
    12·2 answers
  • Which logging category does not appear in event viewer by default?
    11·1 answer
  • Question 1<br> a node is.<br> •a sever<br> A Cell Phone<br> A Laptop<br> a device on a network
    13·1 answer
  • Given variables first and last, each of which is associated with a str, representing a first and a last name, respectively. Writ
    13·1 answer
  • The reliance on _____ as the design methodology for relational databases is seen as a stumbling block to its use in OLAP systems
    5·1 answer
  • Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te
    13·1 answer
  • Describe how both IPv4 and IPv6 access and utilize TCP as an upper-layer transfer protocol.
    6·1 answer
  • Scientist Galileo Galilei used the
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!