The assignment is:

A. Present a menu like the following:

1. Enter a char
2. Enter a string
3. Enter a float
4. Enter an integer
5. Display the sqaure of numbers from 1-100
9. Quit the Program

Enter the Program

B.The program should not quit until the user chooses to quit by entering "9". You must use either a do/while loop or a while loop for this purpose.

C. Depending on the choice the user makes, allow the user to enter that variable type, display it on the screen and prompt for themenu again.

D. For choice 2 (Enter a String) in the menu, output the string user entered as all lowercase and all uppercase letters.

E. For choice 3 and 4 from the menu in step 1,, if the number the user entered was negative, display a message: "You entered a negative number." Similarly, if the user enered a positive number, display: "You entered a positive numbers."

F. For choice 5, use an integer variable. Must use a "for" loop to display the squares of all numbers from 1-100. Example output:
Square of 1 is 1
Square of 2 is 4
Square of 3 is 9
.....
Square of 100 is 10000


BELOW are the code i wrote so far. Im stuck on Part C. And I don't know where to add the code for PArt C-E. Any help would be appreciated.

#include "stdafx.h"
#include <stdio.h>


int main (void)
{
	int myChoice;
	
	do
	{
	printf ("\nMAIN MENU\n\n");

	printf ("1. Enter a char\n");
	printf ("2. Enter a string\n");
	printf ("3. Enter a float\n");
	printf ("4. Enter an integer\n");
	printf ("5. Display the square of numbers from 1-100\n");
	printf ("9. Quit the Program\n\n");

	printf ("Enter your choice. ");
	scanf_s ("%i", &myChoice);

	} 
	while (myChoice != 9);
	return 0;
}

Edited 6 Years Ago by EvilNerd: n/a

I would recommend
1) in the loop
2) after you input the choice.
3) probably using a switch statement or a series of if statements. Functions would be useful too.

Also, I would recommend not using scanf_s() -- or any of the *_s() functions -- because they are useful in only one single compiler. Once you graduate beyond this compiler you will have to relearn a fair amount.

ill give you an example i assume your using vc++ by the syntax

#include <iostream>
using namespace std;

int main(){
float me;
cout<<"enter a float: ":
cin>>me; //takes input (for now float) and stores it including me
cout<<"\n "<<me;
cin.get(); //pause for input though this has other use's too
This article has been dead for over six months. Start a new discussion instead.