Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [1]Input //Allow user to input integers individually in the array.
- [2]Delete //Delete a certain integer from the array.
- [3]Destroy //Remove all values from the array
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <windows.h>
- int menu();
- int MenuNavigation(int rPosition,int nPosition);
- int opt1();
- int opt2();
- int opt3();
- int main()
- {
- int x;
- for(;;)
- {
- x = menu();
- if(x == 1)
- {
- return 0;
- }
- }
- getch();
- return 0;
- }
- int menu()
- {
- system("cls");
- int position = 1;
- int kPress = 0;
- while(kPress != 13)
- {
- system("cls");
- printf("n");
- MenuNavigation(1,position); printf(" INPUT ARRAYn");
- MenuNavigation(2,position); printf(" DELETE ARRAYn");
- MenuNavigation(3,position); printf(" DESTROY ALL ARRAYn");
- MenuNavigation(4,position); printf(" QUITn");
- printf("nnUse arrow keys to navigate the Menu and Press Enter key to Enter");
- kPress = getch();
- if(kPress == 80 && position != 4)
- {
- position++;
- }
- else if(kPress == 72 && position != 1)
- {
- position--;
- }
- else
- {
- position = position;
- }
- }
- if(position == 1)
- {
- opt1();
- }
- else if(position == 2)
- {
- opt2();
- }
- else if(position == 3)
- {
- opt3();
- }
- else if(position == 4)
- {
- return 1;
- }
- /*switch(position)
- {
- case 1:
- opt1();
- menu();
- break;
- case 2:
- opt2();
- break;
- case 3:
- opt3();
- break;
- case 4:
- printf("nnnEXITTING PROGRAM PRESS ANY KEY TO CONTINUE...");
- getch();
- return 0;
- }*/
- }
- int MenuNavigation(int rPosition,int nPosition)
- {
- if(rPosition == nPosition)
- {
- printf("[X]");
- }
- else
- {
- printf(" ");
- }
- }
- int opt1()
- {
- system("cls");
- int arr[20];
- printf("INPUT ARRAYn");
- printf(">>");
- scanf("%d", &arr);
- printf("nn");
- for(int l=0;l<1;l++)
- {
- printf("nData[%d] = %d",l,arr[l]);
- }
- printf("nnArray STORED! Returning back to main menu...");
- getch();
- return arr[20];
- }
- int opt2()
- {
- int pos,i;
- int *arr;
- system("cls");
- printf("DELETE ARRAYnn");
- printf("Enter the element position of the array to deleten");
- printf(">>");
- scanf("%d", &pos);
- if(pos==20+1 || pos<0)
- {
- printf("Invalid position! Please enter position between 1 to 20");
- }
- else
- {
- for(i=pos-1; i<20-1; i++)
- {
- arr[i] = arr[i + 1];
- }
- }
- printf("nElements of array after delete are : ");
- for(i=0; i<20; i++)
- {
- printf("%dt", arr[i]);
- }
- }
- int opt3()
- {
- //int *arr;
- //arr = opt1();
- //printf("%d",*arr);
- }
Add Comment
Please, Sign In to add comment