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
Tcecarenko [31]
2 years ago
14

This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. It is strongly

suggested to use the for loop for this solution.
(1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character.


(2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches triangleHeight. Output a space after each user-specified character, including after the line's last user-specified character.


Example output for triangleChar = % and triangleHeight = 5:


Enter a character:

%

Enter triangle height:

5


%

% %

% % %

% % % %

% % % % %


#include

< stdio.h >


int main(void) {

char triangleChar;

int triangleHeight;


printf("Enter a character:\n");

scanf("%c", &triangleChar);


printf("Enter triangle height:\n");

scanf("%d", &triangleHeight);

printf("\n");


printf("* \n");

printf("* * \n");

printf("* * * \n");


return 0;

}
Computers and Technology
1 answer:
nasty-shy [4]2 years ago
4 0

The program illustrates the use of loops;

Loops are program statements that are used to perform repetition

<h3>The complete program</h3>

The modified program in C, is as follows:

#include<stdio.h>

int main(void) {

   char triangleChar; int triangleHeight;

   printf("Enter a character: ");    scanf("%c", &triangleChar);

   printf("Enter triangle height: ");    scanf("%d", &triangleHeight);

   for (int i = 0; i<triangleHeight; i++){

       printf("\n");

       for(int j = 0;j<=i;j++){

           printf("%c",triangleChar);

       }

   }

   return 0;

}

Read more about loops at:brainly.com/question/24833629

#SPJ1

You might be interested in
I have no idea how to use the sep and end in Python can someone help me I have a test tomorrow
Nuetrik [128]

Answer:

The end parameter basically prints after all the output objects present in one output statement have been returned. the sep parameter differentiates between the objects.

Explanation:

Hope this helps

https://www.edureka.co/community/53505/difference-between-end-and-sep#:~:text=end%20and%20sep%20are%20optional,parameter%20differentiates%20between%20the%20objects.

4 0
3 years ago
Write a c program that reprints input so that no line is longer than 50 characters. Specifically, for lines less than or equal t
Alex73 [517]

Using the knowledge in computational language in C++ it is possible to write a code that reprints prints input so that no line is longer than 50 characters.

<h3>Writting the code:</h3>

<em>#include<stdio.h></em>

<em />

<em>int main(int argc, char** argv){</em>

<em>    //creating pointer to read a file</em>

<em>    FILE * fp;</em>

<em>    char * line = NULL;</em>

<em>    size_t len = 0;</em>

<em>    ssize_t read;</em>

<em>    int i=0;</em>

<em>    //opening a file</em>

<em>    fp = fopen(argv[1], "r");</em>

<em>    //handling the error condition</em>

<em>    if (fp == NULL){</em>

<em>        printf("File not found..!!");</em>

<em>        return 0;</em>

<em>    }</em>

<em>    int moreThan50 =0;</em>

<em>    //reading a file line by line</em>

<em>    while ((read = getline(&line, &len, fp)) != -1) {</em>

<em>        i = 0;</em>

<em>        if(read >= 50){</em>

<em>            moreThan50++;</em>

<em>        }</em>

<em>        while(i < read){</em>

<em>            if(line[i]!='\n'){</em>

<em>                if(i%50 == 0){</em>

<em>                    printf("\n%c",line[i]);</em>

<em>                }else{</em>

<em>                    printf("%c",line[i]);</em>

<em>                }</em>

<em>            }</em>

<em>            i++;</em>

<em>        }</em>

<em>    }</em>

<em>    printf("\nTotal lines over 50 chars: %d\n",moreThan50);</em>

<em>    printf("Offending Lines: ");</em>

<em>    for(i=1;i<=moreThan50;i++)</em>

<em>        printf("%d, ",i);</em>

<em>    fclose(fp);</em>

<em>    return 0;</em>

<em>}</em>

See more about C++ at brainly.com/question/19705654

#SPJ1

4 0
2 years ago
I was designed to meet the computing needs of an individual. I was originally referred to as ___________________.
slamgirl [31]
C) microcomputers
explanation: designed for computing needs of an individual
6 0
3 years ago
Name two word processor<br><br>​
Irina18 [472]

Answer:

the bat hunter

Explanation:

3 0
4 years ago
Describe a problem you’ve solved or a problem you’d like to solve. It can be an intellectual challenge, a research query, an eth
iogann1982 [59]

Answer:

Explanation:

I run an online e-commerce store and lately its been very difficult keeping track of customer detail, incoming orders, keyword generation etc. One solution that I thought about would be an application that controls all of that for me. In order to accomplish this I would first need to design and create a GUI that contains all of the necessary buttons and displays for the information. Then I would need to code a webscraper using Python to grab all of the data from e-commerce store as soon as it becomes available, organize it, and display it within the GUI.

6 0
3 years ago
Other questions:
  • What does the "e" in eSATA stand for?
    13·2 answers
  • Jacob would like to include an arrow in his newsletter to point to some important information. He should _____.
    14·2 answers
  • To be a successful computer systems engineer, you must be proficient in programming languages and operating systems. Similarly,
    5·2 answers
  • How is a technical certificate like a computer-related associate degree?
    12·2 answers
  • Which user characteristic may not be used to change keyword bids in adwords?:?
    11·1 answer
  • The keys to successful outsourcing are accountability, reporting, and ___
    7·1 answer
  • Android OS "AFTER" Beta.<br><br> A. Cupcake<br><br> B. Candy<br><br> C. Cookie<br><br> D. Carmel
    12·1 answer
  • Differents<br>DIFFE<br>RENTIATE BETWEEN FORMULA &amp; A FUNCTION Giving Example​
    8·1 answer
  • What are the different parts of a word processing program?<br><br> I need this ASAP please help!!
    6·1 answer
  • A ________ is a small, lightweight, power-conserving, computing device that is capable of wireless connectivity.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!