answer.
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
Leto
20 days ago
9

Input a number [1-50] representing the size of the shape and then a character [x,b,f] which represents the shape i.e. x->cros

s, b->backward slash, or f->forward slash. Here are 4 examples which give the 2 inputs with the shape of the result directly below. Note: Even number outputs are different from odd.
Computers and Technology
1 answer:
Harlamova29_29 [932]20 days ago
4 0

Response:

C++ code provided below with suitable annotations

Clarification:

pattern.cpp

#include<iostream>

using namespace std;

void printCross(int n)

{

int i,j,k;

if(n%2) //odd number of lines

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==i || j==(n-i+1))

cout<<j;

else

cout<<" ";

}

cout<<"\n";

}

}

else //even number of lines

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==i || j==(n-i+1))

{

cout<<" "<<j<<" ";

}

else

cout<<" ";

}

cout<<"\n";

}

}

void printForwardSlash(int n)

{

if(n%2)

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==n-i+1)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

else

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==(n-i+1))

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

void printBackwardSlash(int n)

{

if(n%2) // odd number of lines

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==i)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

else //even number of lines

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==i)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

int main()

{

int num;

char ch;

cout<<"Create a numberes shape that can be sized."<<endl;

cout<<"Input an integer [1,50] and a character [x,b,f]."<<endl;

cin>>num>>ch;

if(ch=='x' || ch=='X')

printCross(num);

else if(ch=='f' || ch=='F')

printForwardSlash(num);

else if(ch=='b' || ch=='B')

printBackwardSlash(num);

else

cout<<"\nWrong input"<<endl;

return 0;

}

You might be interested in
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
8_murik_8 [892]

Answer:

// C++ program.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

  // variable

float n;  

cout<<"Enter the initial value:";

//User input

cin>>n;

//Variables for measurements at 6, 12, and 18 hours

float hours_6, hours_12, hours_18;  

//Set floating-point precision

cout << fixed;

    cout << setprecision(6);

 //Calculate caffeine amounts after 6, 12, 18 hours

hours_6 = n / 2.0;

hours_12 = hours_6 / 2.0;

hours_18 = hours_12 / 2.0;

//Display results

cout<<"After 6 hours: "<<hours_6<<"mg"<<endl;

cout<<"After 12 hours: "<<hours_12<<"mg"<<endl;

cout<<"After 18 hours: "<<hours_18<<" mg"<<endl;

return 0;

}

Explanation:

The program reads input from the user and sets the output precision to six decimal places. The caffeine amount after 6 hours is half the initial input. At 12 hours, it is half the 6-hour value, and after 18 hours, it is half the 12-hour value.

Output:

Enter the initial value:100

After 6 hours: 50.000000 mg

After 12 hours: 25.000000 mg

After 18 hours: 12.500000 mg

5 0
1 month ago
What is an artificial intelligence system that mimics the evolutionary, survival-of-the-fittest process to generate increasingly
amid [805]
Answer: genetic algorithm


Explanation: A genetic algorithm is a smart system that imitates the natural process of evolution to develop progressively better solutions toward a specific challenge. These algorithms are commonly utilized in the design of components for aircraft, such as fan blades, among other applications.
5 0
27 days ago
They predicted another cold day in Seattle. They predicted another windy day in Seattle. Combine the sentences into one sentence
8_murik_8 [892]

Answer:

They forecasted yet another cold day in Seattle combined with another day of wind.

4 0
1 month ago
A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a ser
zubka84 [945]

A computer functions as a multifunctional device that accepts input, processes that data, stores it, and generates output based on a series of saved instructions. The central processing unit in most contemporary computers consists of a microprocessor. Instructions that dictate how a computer executes tasks are known as computer programs, which are disseminated as software. Computers operate with three primary categories of software: Application software, system software, and development tools. A prime example of system software is an operating system, which essentially acts as the main controller for all operations that a digital device undertakes. Digital devices are built from small electronic components that symbolize data bits through electrical signals. The system unit contains the system board, which is composed of several integrated circuits made from semiconducting materials. Computers are available in three widely used form factors: component, clamshell, and slate. Today's digital devices typically run on battery power provided by Lithium ion batteries. Proper battery management practices can prolong battery life and lifespan.

Clarification

Computers are capable of accepting input, processing data, storing it, and producing output according to preset instructions. Input refers to data or information that a user enters into a computer. Processing involves calculating, graphing, altering documents, and performing numerous other operations. The results are output, produced by the computer. This processing is managed by the CPU (Central Processing Unit), which in most modern machines is a microprocessor. The microprocessor executes and coordinates all logical instructions it receives, managing tasks related to data processing. Programs, which are grouped under software, are ordered operations on a computer that complete specific functions. These programs are formulated and compiled in a language that the computer understands before being distributed as software. The three main types of software include application software, system software, and development tools. Application software aids users in achieving specific tasks, while system software empowers the computer to self-manage effectively. In contrast, development tools are utilized to build applications, operating systems, websites, and utilities. Digital electronics rely on tiny electrical components representing data bits as signals. The core of digital equipment consists of miniature circuit boards and integrated circuits visible when accessing a digital device. Integrated circuits are groups of electronic circuits imprinted onto a thin sheet of semiconducting material. Computers exist in three common form factors: component, clamshell, and slate. In computing, form factor pertains to the device's dimensions and overall size. Clamshell devices are distinguished by a design comprising a keyboard on the base and a screen atop a hinged lid, whereas slate devices prominently feature a touchscreen across most of their surface. Majority of modern digital gadgets depend on battery power sourced from Lithium ion batteries, where smart battery management can enhance battery longevity.

7 0
1 month ago
Farrah plans to use BlackAdder, a multiple-language IDE, to develop software code. What must she consider before using this IDE?
zubka84 [945]

Answer:

Either A or D

Explanation:

In my opinion

8 0
28 days ago
Read 2 more answers
Other questions:
  • You're installing two new hard drives into your network attached storage device. Your director asks that they be put into a RAID
    15·1 answer
  • A have a string, called "joshs_diary", that is huge (there was a lot of drama in middle school). But I don't want every one to k
    5·1 answer
  • python Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value i
    7·1 answer
  • Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
    6·2 answers
  • Allan needs to ensure that an object is in a very precise location on a slide. He decides to use the Ruler option to achieve thi
    5·2 answers
  • A retailer is able to track which products draw the most attention from its customers through the use of 5g-enabled motion senso
    5·1 answer
  • Discussion Question 10: A bank in California has 13 branches spread throughout northern California , each with its own minicompu
    13·1 answer
  • The piston engine uses the ________ to convert the reciprocating motion of the piston into rotary motion.
    13·1 answer
  • Which selections are possible for controlling the start time of audio playback? Check all that apply. Automatic Rewind when done
    10·1 answer
  • Mia is disappointed with how her latest video games are playing on her computer; the images are slow
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!