Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement Please modify the following code to use only the DO - WHILE loops. The program prompts a user for an integer input. It

Problem Statement
Please modify the following code to use only the DO-WHILE loops. The program prompts a user for an integer input. It takes an input as a size of a triangle. The program will output the triangle to the screen.
#include
int main()
{
int size =0;
int i =0;
int j =0;
//prompt a user for an input
printf("Please input an int as a size of a triangle: ");
scanf("%d", &size);
//output a triangle to the screen
printf("
*****Print triangle*****
");
for( ;i < size; i++){
j = i+1;
while(j-->0){
printf("#");
}
printf("
");
}
return 0;
}
Output example
Please input an int as a size of a triangle: 5
*****Print triangle*****
#
##
###
####
#####
Partial Solution
Please try to implement the assignment code in your IDE first and compare your source code with the following partial solution code. Complete the following code for the assignment credit.
#include
int main()
{
int size =0;
int i =0;
int
j
=0;
//prompt a user for an input
printf("Please input a int as a size of a triangle: ");
scanf("%d",
&size
);
//output a triangle to the screen
printf("
*****Print triangle*****
");
do
{
j = i+1;
while
{
printf("#");
}
(--j
0);
printf("
");
}
(++i
size )
return
;
}

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago