Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Basic C++ programming. I have not learned much about C++ so please use just simple code. Thanks First part : using cout ----------------------- always include

Basic C++ programming. I have not learned much about C++ so please use just simple code. Thanks

First part : using cout

-----------------------

always include at the top of a code-block a display like:

// ****** First part ******

cout

25. For the first part, implement the source code to display an output as:

1 2 3 4

using cout, endl, , in the following consecutive versions:

1 using one cout statement, with the numbers as one string;

2 - using one cout statement, with four cascaded string-inputs;

3 - repeat, using integer numbers as four inputs (you must insert spaces as " ";

4 - repeat, using characters;

5 - using four individual cout statements, and using only one string at a time (insert space-separator in every string).

26. At the end of this first part, and also at the end of all following sections, pause using:

system("pause"); // it displays: Hit any key to continue

system("cls");

Second part : using printf_s()

--------------------------------

27. Use printf_s() instead of cout, for all above implementation versions.

Before you start adding the new code, comment out the code already implemented for cout, using the preprocessor directives

#if and #endif.

And do the same thing for all sections to be implemented next.

In the end, de-activate the two preprocessor-directives using // in front of them, to run all implemented-sections, from the top to the end of the project-source-code.

Here are some implementation-examples for this second printf

section:

printf("%d %d ", 1, 2); // space inside the control-string

printf("%s%s ", "1 ", "2 "); // space inside the

// displayable strings

You may also use

scanf_s("%c", &ch, 1); // to insert a pause

instead of system("pause");

Note: the old version scanf_s("%c", &ch) is no longer recommended. Try it. You get an warning: not enough arguments passed.

Third part : display a table

----------------------------

28. Implement a source code, using cout, to display the table:

number square cube

1 1 1

2 4 8

3 9 27

with columns displayed at a TAB distance (\t):

- declare an int variable n, initialized to 1;

- using operators ++ and * to move n from 1 to 27

- from 1 to 2, use n++

- from 2 to 4, use n*n

- and so on.

Note: the cube column doesnt display the values right-justified.

Fourth part : display a triangle

--------------------------------

29. Display a triangle using cout with only one input-string:

*

**

***

****

*****

Fifth part : display a rectangle

--------------------------------

30. Implement a source code, using cout, to display a rectangle:

^ ------------------

| | |

a | |

| | |

v ------------------

* Sample output

image text in transcribed

eIcome to C+ utput displayed using cout Inplenent code to display the output as -using e cout' statenent. with the numbers as one string 2-using one statement with four cascaded string-inputs 11 3 23 -repeat, using integer numbers as four inputs 1-repcat, using character:3 s as one string "; 1 2 3 1 using four individual cout' statenents using only one string at a tine 2 3 ng-inputs In" Press any key to continue-.. _ cout

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions