DnsMonsteR7712
19.07.2019 •
Computers and Technology
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
Solved
Show answers
More tips
- W Work and Career How to Start Your Own Business: Tips and Recommendations...
- S Society and Politics 10 Tips for Boosting Your Self-Esteem...
- C Computers and Internet How to Create a Folder on Your iPhone?...
- G Goods and services How to sew a ribbon: Tips for beginners...
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
Answers on questions: Computers and Technology
- C Computers and Technology Can your digital footprint be destroyed or does it remain active on the internet forever...
- S Social Studies Why is it a bad idea to assume that family preservation is always the best option? a. family preservation rarely works with single-parent families. b. most family social workers...
- S Social Studies According to dan gilbert, the first stage of the attributional process entails making attributions that are the second, adjustment, stage entails making that are a. dispositional;...
- B Biology Why is the structure of dna called a double helix? a.because each of the curved dna subunits appears twice whenever it appears b.because dna is made of two strands of nucleotides...
- M Mathematics Set operations including cardinality of power sets and listing the elements of a power set and finding the number of subsets of a given size. let u = {-1, 0, 1, 2, 3, 4, 6} , a =...
- S Social Studies Aresearch report includes this paragraph: we hypothesized that anxiety disorders are more frequent in children whose parents are divorced. we looked at the frequency of anxiety problems...
- B Biology How does fox in the snow relate to the cycle of life?...
- H History Howdideuropean nations competeto build newcolonies in the americas?...
- H History How did great britain and the united states differ in their responses to the depression?...
- H History In the united states, a. the legislative and executive branches have gradually come to share all institutional powers b. legislative powers include the ability to initiate and implement...
Ответ:
#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 '*'.
Ответ:
Hope my answer would be a great help for you. If you have more questions feel free to ask here at .