@Matticus-
Thats the part im confused about. In my original code, those "random" numbers you say are being printed out are what I want to be my array that case 'F' fills with.
So to explain, what prints out from 'P' I want to be my array.
I've added the do/while loop, but its not correct. If I press: f, p or q it gives me the menu still regardless.
Code:
// This program will write a menu-driven program that allows the user to:
// fill an array, query the array, and print the array.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 50
int main(){
int range;
int i;
char choice;
char Z, z;
int array[SIZE];
// Array elements will range from 1-999
srand (time(NULL));
range = rand() % (999 - 1) +1;
do{
printf("******MENU******\n");
printf("F. Fill the array with a random number series.\n");
printf("P. Print the array.\n");
printf("Q. Query the array.\n");
printf("Z. Terminate the program.\n");
printf("\n");
printf("Select one of the following options:\n");
scanf("%c", &choice);
switch(choice){
case 'F' : case 'f':
printf("Please wait while the array is being filled...\n");
printf("Process is complete.\n");
break;
case 'P' : case 'p':
for(i = 0; i < SIZE; i++){
printf("%i ", rand() %(999 - 1) +1);}
break;
case 'Q' : case 'q':
printf("Please enter element you would like to query:\n");
case 'Z' : case 'z':
printf("Goodbye\n");
return(0);
default:
printf("Please select from the menu\n");}
}
while(choice != Z || z);
return (0);
}