Question

Question-4 1- Get a number from user. (i.e. number = 10) 2. Draw the pattern as you see in sample run based on the number you
0 0
Add a comment Improve this question Transcribed image text
Answer #1

As you haven't mentioned any coding language in the question. So i am doing it in three different coding languages.

I have compiled the code on all the three languages on compiler.

Refer to the images for the answers:

1. In C++ language

main.cpp 1 #include <iostream> 2 using namespace std; 3 int main() 4- { int number; cout<<Enter a number:; cin>>number; for

2. In C language

main.c 1 #include <stdio.h> 2 int main() ол нь int number; printf(Enter a number:); scanf(%d,&number); for(int i=number;i

3. In python language

main.py 1 number = int(input(Enter a number:)) 2 vouw 3 for i in range(number, o, -1): for j in range(0, i): print(*, end

I appreciate if you like the answer.
Thank you

Add a comment
Know the answer?
Add Answer to:
Question-4 1- Get a number from user. (i.e. number = 10) 2. Draw the pattern as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The...

    1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...

  • Java Programmming Given three numbers from user input, decrement the first number by 2 and increment...

    Java Programmming Given three numbers from user input, decrement the first number by 2 and increment the second number by 1, Then do the magic calculations as follows: get the sum of the first two numbers, deduct the third number from the second and get the product of the first and third number, then sum up the results of the three magic calculations. Sample run 1:                                     Enter three numbers separated by spaces: 4 2 3      Output: Result of Magic calculations...

  • IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we...

    IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we do the following: If the integer is odd, we multiply by 3 and add 1. If the integer is even, we divide by 2. It is hypothesized that the above sequence will always converge to the value of 1, regardless of any valid initial choice. This hypothesis is known as the Collatz Conjecture. For example, if we start at 5, the numbers generated by...

  • build a phone number from digits entered by your user. Your program will loop until 10...

    build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...

  • use java thanks Write a program that prompts a user to enter number of Math question that she wishes the system to gene...

    use java thanks Write a program that prompts a user to enter number of Math question that she wishes the system to generate. The system will random generate Math questions which consisted of ±' , x and / of two positive integer numbers. The sample run programs are depicted as below Sample run 1 How many Math question you want to create? 4 Sample run 2 How many Math question you want to create? 10 4 questions have been created...

  • **Using C Language** Get a number from the user and use that number for loops and...

    **Using C Language** Get a number from the user and use that number for loops and to make some calculations. Get a number from the user (n) (For example if the user enters a 3, each loop below will repeat 3 times) //ask, get, and return an integer (by reference) void GetIntPointer(int *numPtr); //input: the number entered by the user (pass by copy) //Calculates the product of the first (n)numbers using a while loop and store the result in *productPtr...

  • This program is to ask the user N number of math (using only +, -, *,...

    This program is to ask the user N number of math (using only +, -, *, and /) questions. Once the program start it asks the user to enter how many questions will be asked (N, which is between 3-10). Then, the program asks N questions to the user. Each question will be one of four math operations (+, -, *, and /). The operation and operands will be selected randomly in your program.Operand are “unsigned short” between 0 and...

  • Question 3.1 Draw the class diagram for the ATM program in Question 2.1. Please find attached...

    Question 3.1 Draw the class diagram for the ATM program in Question 2.1. Please find attached the scenario in the photos. this is for programming logic and design Scenario A local bank intends to install a new automated teller machine (ATM) to allow users (i.e., bank customers) to perform basic financial transactions (see below figure). Each user can have only one account at the bank. ATM users should be able to do the following; View their account balance. Withdraw cash...

  • Write a C++ program that repeatedly collects positive integers from the user, stopping when the user...

    Write a C++ program that repeatedly collects positive integers from the user, stopping when the user enters a negative number or zero. After that, output the largest positive number entered. A sample run should appear on the screen like the text below. Enter a number: 3 Enter a number: 10 Enter a number: 2 Enter a number: -213 Output: The largest positive number you entered was 10.

  • Create a JAVA program that in two numbers from user input, the program then does the...

    Create a JAVA program that in two numbers from user input, the program then does the following arithmetic calculations. The program will run in ascending order if the first number is small and in descending order of the first number is bigger. The program then alternates between addition(ODD) and subtraction(EVEN) depending on the previous number see examples below   [15] Sample run 1: Enter two numbers: -3 2 Output: The following arithmetic calculations were performed : Arithmetic operations = (-3) +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT