Question

Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program of the followi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE OF THE FOLLOWING PROGRAM:-

#include <stdio.h>
#include <stdlib.h>

int main()
{   
  
char choice;
int j=1,num;
//if J is less than equal to 9
while(j<=9){
printf("Input an integer number\n");
scanf("%d",&num);
//if number entered is less than j or greater than 20. User will enter again
while(num<j || num>20){
printf("Number must be greater or equal to j and less or equal than 20,enter input again\n");
scanf("%d",&num);
}
//Menu & asking user to enter a choice
printf("Choose one of the following menu\n");
printf("X: print '*' num times\n");
printf("Y: print '#' num times\n");
printf("Z: Exit from the program\n");
scanf(" %c",&choice);
  
//If the entered choice is not x,Y or Z enter again
while(choice!='X' && choice!='Y' && choice!='Z'){
printf("Wrongly enter,enter again\n");
scanf(" %c",&choice);
}
  
//If the entered choice is X,Y or Z do as per menu
if(choice=='X'){
//If user choice is X
for(int i=0;i<num;i++)
printf("*");
printf("\n");
}
else if(choice=='Y'){
//If user choice is Y
for(int i=0;i<num;i++)
printf("#");
printf("\n");
}
else if(choice=='Z'){
// Terminate if user choice is Z
exit(0);
}
}
return 0;
}

SCREENSHOT OF THE PROGRAM AND SAMPLE OUTPUT:-

9 #include <stdio.h> 10 #include <stdlib.h> 12 int main() 15 char choice; int j=1, num; //if j is less than equal to 9 while(//If the entered choice is x, y or Z do as per menu if(choice==){ //If user choice is X for(int i=0;i<num;i++) printf(*);SAMPLE OUTPUT:

input Input an integer number Number must be greater or equal to j and less or equal than 20, enter input again Choose one ofHAPPY LEARNING

Add a comment
Know the answer?
Add Answer to:
Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program...
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
  • Subset Sum-2 Write an algorithm (in comments) and specify the big O, and a C program...

    Subset Sum-2 Write an algorithm (in comments) and specify the big O, and a C program to solve the problern below. Read the input for the set elements, the value of K from the user. Assume the size of the set is not bigger than 20. Subset Sum-3 Write an algorithm (in comments) and specify from the user. Assume the size of the set is not bigger than 20 1. Given a finite set of integers, is there a subset...

  • Write a C++ program that will display the following menu and work accordingly. A menu that...

    Write a C++ program that will display the following menu and work accordingly. A menu that will display the following choices and uses functions to carry out the calculations: 1. Call a function named classInfo() to ask the user the number of students and exams in a course. 2. Call a function getGrade() that will get the information from classInfo() and asks the user to enter the grades for each student. 3. Call a function courseGrade() to display the average...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • Answer in C using basic C and loops. ASSIGNMENT: Write a program that will display how...

    Answer in C using basic C and loops. ASSIGNMENT: Write a program that will display how many times a ball will bounce until its height is less than 1 inch. A ball has a property called the coefficient of restitution, a number between 0.0 and 1.0, that indicates how 'bouncy' the ball is. A coefficient of restitution of .5 means that the ball will bounce-up 50% of its initial height after each bounce Write a program to ask the user...

  • Project 1, Program Design 1. Write a C program replace.c that asks the user to enter...

    Project 1, Program Design 1. Write a C program replace.c that asks the user to enter a three-digit integer and then replace each digit by the sum of that digit plus 6 modulus 10. If the integer entered is less than 100 or greater than 999, output an error message and abort the program. A sample input/output: Enter a three-digit number: 928 Output: 584 2. Write a C program convert.c that displays menus for converting length and calculates the result....

  • Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your...

    Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of...

  • Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...

    Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...

  • Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to...

    Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...

  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

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