Objectives use a switch/case statement create a void function call a void functi
ID: 3741759 • Letter: O
Question
Objectives use a switch/case statement create a void function call a void function without an argument e e e call a void function with an argument Tasks: Write a program that gives the user 2 menu options: either call a function that will print a greeting and your name 5 times or call a function that will display the squares of the numbers from 12 to 0 in the format shown in the example. Both functions should use for loops to print the appropriate output Write a program that prints 6 bar graphs with hashtags like shown in the example at the bottom of the page. A function that accepts the length (number of hashtags) should be created and then called 6 different times to print the graphs. Use input validation to make sure that a user enters a positive number that is less than or equal to 36 Follow these steps for Lab 10: 1. Create a new file named YourLastNameLab10-Menu.c. 2. In the main function, display a prompt (like shown in the first 2 examples below the instructions) asking the user to choose 1 of 2 options. If the user does not enter 1 or 2, repeat the prompt until they do. Please avoid calling the main() function recursively to accomplish this behavior 3. If the user does choose 1 or 2, use a switch/case statement to evaluate the user's choice and call an appropriate function. a. If the user chooses 1, call a descriptively-named function that uses a for loop to print Hi, my name b. If the user chooses 2, call a descriptively-named function that uses a for loop to print the squares of 4. Take a screen clipping of the program that shows the output generated if the user chooses the first option, is Chris.five times. Be sure to use your own first name the numbers from 12 to 0 in the format: 12 x 12 144 and paste the image in a word processing document named YourLastNameLab10. Take a screen clipping of the second option and paste that in the document as wellExplanation / Answer
Hi,
Please find the below program.
#include<stdio.h>
void myName();
int numberSquare(int a);
int main()
{
int operation;
printf("What would you like to do ? ");
printf("1- Print my Name ");
printf("2- Show squares of numbers from 12 to 0 ");
scanf("%d",&operation);
switch(operation)
{
case 1:
myName();
break;
case 2:
numberSquare(12);
break;
default:
printf("wrong choice ");
}
return 0;
}
void myName()
{
for(int i=0;i<5;i++){
printf("Hi, my name is Chris. ");
}
}
int numberSquare(int a)
{
int val;
int i=a;
for(;i<=a;i--){
val = i*i;
printf("%d" "*" "%d" "=" "%d ", i, i, val);
if(i==0){
break;
}
}
}
Output: When we select option 2.
What would you like to do ?
1- Print my Name
2- Show squares of numbers from 12 to 0
2
12*12=144
11*11=121
10*10=100
9*9=81
8*8=64
7*7=49
6*6=36
5*5=25
4*4=16
3*3=9
2*2=4
1*1=1
0*0=0
=======
When we select option 1 => Please change the name in the program to your name. Below is the example.
What would you like to do ?
1- Print my Name
2- Show squares of numbers from 12 to 0
1
Hi, my name is Chris.
Hi, my name is Chris.
Hi, my name is Chris.
Hi, my name is Chris.
Hi, my name is Chris.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.