Menu-driven Program in C for creating and Display Integer

Design, Develop and Implement a menu-driven Program in C for the following Array Operations
a. Creating an Array of N Integer Elements
b. Display of Array Elements with Suitable Headings
c. Exit

#include<stdio.h>
#include<stdlib.h>
int n,i;
int ele[100];
void create(){
    printf("Enter the number of elements you want to enter: ");
    scanf("%d",&n);
    for(i=0; i<n; i++){
        printf("Eneter the %dst Element : ",i+1);
        scanf(" %d",&ele[i]);
    }
    printf("\nData Stored !!");
}

void display(){
    printf("The Stored Data is ::\n");
    for ( i = 0; i < n; i++)
    {
        printf(" %d ",ele[i]);
    }
    
}

void main(){
    while (1)
    {
    
        int option;
        printf("\nSelect the Option based on your choice :: \n 1.Create \n 2.Display \n 3.Exit\n");
        scanf("%d",&option);
       switch (option)
       {
           case 1:create();
           break;
           case 2:display();
           break;
           case 3:exit(0);
           break;
       
           default:printf("Please select Correct option !!");
           break;
        }
    }

}

Leave a Reply

Your email address will not be published. Required fields are marked *