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

1. Create an optimized function "print s(n,s)" that prints the given argument s (representing a string) k times. k represents th

e number of iterations of the inner loop. The print statement that prints s is in the inner loop of the function (a) Initial conditions: i = 1, j = 1, i <= n, and j <= i (b) i and j increments: i = i + 1 and j = j ∗ 2 (c) input as arguments in the function: n (an integer representing the size of the input), and s (the string) (d) output: print s k times (e) example: n=5, s="hello CSC510-01 class", given these conditions, the function "print s(n,s)" will print s 11 times
Computers and Technology
1 answer:
lukranit [14]3 years ago
3 0

Answer:

The program in C is as follows:

void prints(char arr[], int n){

   int count =0;

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

   for(int j=1;j<=i; j=j*2){

   count++;    }    }  

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

       printf("%s ",arr);

   }

}

Explanation:

This defines the method

void prints(char arr[], int n){

This declares and initializes count variable to 0

   int count =0;

This creates the outer loop

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

This creates the inner loop

   for(int j=1;j<=i; j=j*2){

This increments count by 1

   count++;    }    }  

This iterates through count

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

And print the string in count times. If count is 3, the string will be printed 3 times.

       printf("%s ",arr);

   }

}

See attachment for complete program that includes the main method

Download txt
You might be interested in
Which chart element provides the boundaries of the graphic?
Eddi Din [679]
The correct option is B.
Chart area is the boundary that contains all the chart and all its elements including the chart titles, legends, plot area, labels, etc.
The legend is the key that identifies the gradient, texture, colour and pattern fill given to each data series. 
The chart title is the label that describe the chart while the plot area is the section of the chart that contains graphical representation of the values in a data series.
7 0
3 years ago
Read 2 more answers
How do you think we could print a sentence that uses a variable along with other text (ie: “My name is Joe” where ‘Joe’ is a var
Sphinxa [80]

This is for Python

name = 'Joe'

print(f'My name is {name}')

This is called string formatting. Using f before the text. This is another way

name = 'Joe'

print('My name is', Joe)

But I found that string formatting is cleaner and much more useful

4 0
2 years ago
1. You have a light in your living room that you can turn on or off from either (A) the living room, or (B) the kitchen.
Ksenya-84 [330]

Answer:

Table lamps or floor lamps with an adjustable head are the ideal fixtures for providing task lighting in living rooms.

Explanation:

3 0
2 years ago
A laptop is running hotter than normal, and its cooling fan sounds slower than usual. Which is the most likely problem?
Katena32 [7]

your laptop has too many programs running and the computer cannot keep up with them which causes the laptop to overheat. the fan is running at a normal pace, it's just not fast enough to cool down the laptop because there are too many programs running bogging down the system.

7 0
3 years ago
Read 2 more answers
Why is it necessary to include units when measuring and dimensioning?
antoniya [11.8K]
Because the measurement is relative to the unit. For example:

A measurement is six. But could be 6 inches, 6 yards, 6 nm, 6 feet, six as a quantity, six packages, six items, etc.

So until you specify the unit, that number means nothing.
7 0
2 years ago
Other questions:
  • What are some examples of the kinds of information that might be included in a career definition section of a career plan? Check
    7·2 answers
  • Don't pat any attention to this
    7·2 answers
  • One of the advantages of off-the-shelf software is that ________________. a. the software contains important features, thus elim
    13·1 answer
  • Which of the following software maintenance steps erases gaps caused by deleting files from the hard drive?
    10·1 answer
  • Which statement outputs a double value in a field of nine characters with three digits after the decimal point?
    13·1 answer
  • What can you find the under the privacy policy section of a shopping website?
    12·1 answer
  • What word can you type using only the left home row keys and the right reach keys?
    6·2 answers
  • Why can’t I see one individual’s questions in the app through their profile, but I can see their questions on the website?
    12·2 answers
  • To delete unnecessary files on a hard disk use software
    5·2 answers
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!