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
I am Lyosha [343]
3 years ago
15

Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has

already been declared, use a for loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j
Computers and Technology
1 answer:
OLEGan [10]3 years ago
6 0

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialize the variables

   int n = 5;

   int j=1;

   // for loop

   for(;j<=n;j++){

       cout<<"*";  //print the '*'

   }

}

Explanation:

Create the main function and declare the variable n with the value 5 and initialize the variable j with zero.

take a for loop for executing the statement again and again until a condition is not false.

Syntax for loop:

for(initialize; condition; increment/decrement)

{

 statement;

}  

we can initialize the variable outside as well but the semicolon always present in the loop otherwise compiler gives the error.

for example:

int i=0;

for(; i<4; i++){

  statement;

}

The condition put in the original code is j <= n and n has the value 5. so, the loop executes 5 times and inside the loop, write the print statement for print the character '*'.

You might be interested in
Gloria is in her sophomore year of college and works part time. She has assignments saved on her home computer, her aunt's lapto
Tanzania [10]
I think this answer, "<span>Upload all existing documents to a cloud-based program," is correct. Hope I helped!!</span>
4 0
3 years ago
Read 2 more answers
The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided
poizon [28]

Answer:

The Java code is given below with appropriate comments for explanation

Explanation:

// java code to contradict birth day paradox

import java.util.Random;

public class BirthDayParadox

{

public static void main(String[] args)

{

   Random randNum = new Random();

   int people = 5;

   int[] birth_Day = new int[365+1];

   // setting up birthsdays

   for (int i = 0; i < birth_Day.length; i++)

       birth_Day[i] = i + 1;

 

   int iteration;

   // varying number n

   while (people <= 100)

   {

       System.out.println("Number of people: " + people);

       // creating new birth day array

       int[] newbirth_Day = new int[people];

       int count = 0;

       iteration = 100000;

       while(iteration != 0)

       {

           count = 0;

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               // generating random birth day

               int day = randNum.nextInt(365);

               newbirth_Day[i] = birth_Day[day];

           }

           // check for same birthdays

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               int bday = newbirth_Day[i];

               for (int j = i+1; j < newbirth_Day.length; j++)

               {

                   if (bday == newbirth_Day[j])

                   {

                       count++;

                       break;

                   }

               }

           }

           iteration = iteration - 1;

       }

       System.out.println("Probability: " + count + "/" + 100000);

       System.out.println();

       people += 5;

   }

}

}

4 0
4 years ago
. Is it conceivable to design a secure operating system for these computer systems? Give arguments for and against.
Lena [83]

Answer:

A favor:  porque permite manejar la memoria, disco, medios de almacenamiento de información y los diferentes periféricos o recursos de nuestra computadora, como son el teclado, el mouse, la impresora, la placa de red, entre otros.

En contra:

Si uno llega a fallar con un codigo en algun sistema puede verse afectado el dispositivo

Explanation:

8 0
3 years ago
How many searches should you complete when looking up information using online references?<br>​
antoniya [11.8K]
As many as it takes of course ;)
3 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
erica [24]

Answer:

Router

Explanation:

Routers have something called a WAN link, which can be used to connect 2 local area networks

7 0
3 years ago
Other questions:
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • When doing a complex presentation, which of the following would be the best tool to begin designing your presentation?
    11·2 answers
  • Which two computer peripherals are connected to the computer through a port?
    9·1 answer
  • You have a site (Site1) that has about 20 users. For the last few months, users at Site1 have been complaining about the perform
    9·1 answer
  • WHAT IS A COMPUTER ????
    14·2 answers
  • In the SQL environment, a _____________ is a logical group of database objects – such as tables and indexes – that are related t
    11·1 answer
  • Write an algorithm that receives a number from the user (you can store the number in a variable called N). Then the algorithm sh
    8·1 answer
  • One of the most common uses of spreadsheet are
    8·1 answer
  • Your program will search for prime numbers. You will first ask the user for the range of values to search, and use for loops to
    6·1 answer
  • Can include the 5-tuple information, which is the source and destination ip addresses, source and destination ports, protocols i
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!