1. [2] Write a program that asks the user for a positive integer, then outputs all the numbersfrom 1 to that number. 2. [2] Write a program that asks the user for a number and prints out that many...

1 answer below »
1. [2] Write a program that asks the user for a positive integer, then outputs all the numbersfrom 1 to that number.
2. [2] Write a program that asks the user for a number and prints out that many stars ona line. Continue asking the user for new numbers until they decide not to.
3. [3] Write a program that asks the user for a number, and then outputs all the factors ofthe number.
4. [3] Write a program that asks the user for a number, and then outputs a pyramid of ‘*’ whose largest layer is the entered number.
5. [2] Write a program that asks the user for a number, then outputs an offset pyramid ofstars with that many layers.
PLEASE VIEW THE DOCUMENT ATTACHED. PLEASE COMPLETE THESE QUESTIONS USING WHILE LOOPS AND AS BASIC JAVASCRIPT AS POSSIBLE. YOUARE NOT ALLOWED TO USE PROMPT BOXES FOR INPUTS. ALL INPUT MUST BE DONE ON THE PAGE ITSELF(IN AN HTML INPUT).


while Loop Challenges Name: /12 Programs For the questions in this section, upload the program, including an appropriate name, to Google Classroom. Note that no data sanitation is required for these programs, although each one should be completed in a separate file. 1. [2] Write a program that asks the user for a positive integer, then outputs all the numbers from 1 to that number. E.g. 1 Please enter a number: 5 2 1 3 2 4 3 5 4 6 5 2. [2] Write a program that asks the user for a number and prints out that many stars on a line. Continue asking the user for new numbers until they decide not to. E.g. 1 Please enter a number: 4 2 **** 3 Do you want to try again? (y/n) y 4 Please enter a number: 7 5 ******* 6 Do you want to try again? (y/n) n 7 Goodbye! Hint: you can use the .repeat(n) function to repeat a string n times. Although you don’t need it to complete this question, it may prove useful! 3. [3] Write a program that asks the user for a number, and then outputs all the factors of the number. E.g. 1 Please enter a number: 18 2 Factors are 1 2 3 6 9 18 4. [3] Write a program that asks the user for a number, and then outputs a pyramid of ‘*’s whose largest layer is the entered number. E.g. 1 Please enter a number: 4 2 * 3 ** 4 *** 5 **** Rev. 2020/05/01 15:28:58 -06’00’ while Loop Challenges 5. [2] Write a program that asks the user for a number, then outputs an offset pyramid of stars with that many layers. E.g. 1 Please enter a number: 4 2 * 3 *** 4 ***** 5 ******* Note: you may not use CSS to create the centring effect. Programming 9 2 CSE1120: Structured Programming 2
Answered 353 days AfterApr 29, 2021

Answer To: 1. [2] Write a program that asks the user for a positive integer, then outputs all the numbersfrom 1...

Shobhit answered on Apr 18 2022
95 Votes
Write a program that asks the user for a positive integer, then outputs all the numbers from 1 to that number
ANSWER 1:
#include
int main()
{
int n;
printf("Enter a positive number:");
scanf("%d",&n);
int i=1;
while(i<=n)
{
printf("%d\n",i);
++i;
}
}
Write a program that asks the user for a number and prints out that many stars on a line. Continue asking the user for new numbers until they decide not to.
ANSWER 2:
#include
int loop(int n)
{
int i=1;
while(i<=n)
{
printf("*");
++i;
}
printf("\n");
}
int main()
{
int n;...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here