Project began on January 21st, deadline set for January 28th.
The purpose of this project is to present a menu that produces various options for the user to access. These options produce links to input statements that obtain integers, display them and manipulate them.
In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:
This programs consists on an array and responds to various loop options.
Array - Holds multiple elements as a list of the same data type.
State the idea or purpose of the project. What are you attempting to pursue?
Upon approval, you'll want to fill this section out with more detailed background information. DO NOT JUST PROVIDE A LINK.
Providing any links to original source material, such as from a project page, is a good idea.
You'll want to give a general overview of what is going to be accomplished (for example, if your project is about installing a web server, do a little write-up on web servers. What is it, why do we need one, how does it work, etc.)
Give a general overview of your anticipated implementation of the project. Address any areas where you are making upfront assumptions or curtailing potential detail. State the focus you will be taking in implementation.
State and justify the attributes you'd like to receive upon successful approval and completion of this project.
At first my capabilities were limited when approaching this project. After some time revising multiple books and examining a few online sources i was confident to begin a pseudo code approach.
This program uses multiple loops which meant revision on the, While…Do, If….Else statements was needed.
A problem that i faced forming the loop structure for the program was in relation to the Switch, Case statment. It took some time nesting loops properly without running into multiple syntax errors.
A problem i faced producing the case 3 & case 4 options of the menu was not having the right data for my 2nd nested loop. Example below.
for (c = 19; c >= temp; c– ) This loop would not run and took me along time to figure out the problem { eventually adding a greater then or equal to sorted out my problem i think.
array[c] = array[c - 1]; }
Upon completion of the project, if there is an applicable collection of created code, place a copy of your finished code within <code> </code> blocks here.
/* * hello.c - A sample "Hello, World!" program * * written by Anthony Pardini for Data Structures on 01/28/15 * */ #include <stdio.h> #include <stdlib.h> int main() { int array[20]; int temp, temp2, stdOut,choice,position,value,c; int flag = 1; for ( c = 0 ; c < 20 ; c++ ) { array[c]=-1; } while(flag == 1) { printf("What would You like to do?\n"); printf("1. Build List\n"); printf("2. display list\n"); printf("3. insert into list\n"); printf("4. append into list\n"); printf("5. obtain from list\n"); printf("6. clear list\n"); printf("7. quit\n"); printf("Enter your choice\n"); scanf("%d", &choice); switch (choice) { case (1): printf("Enter elements\n"); for ( c = 0 ; c < 20 ; c++ ) { printf("Enter number to add: "); scanf("%d", &array[c]); if (array[c] == -1) { break; } } break; case (2): printf("Array elements entered by you are:\n"); for ( c = 0 ; c < 20 ; c++ ) { printf("array[%d] = %d\n", c, array[c]); if (array[c] == -1) { break; } } break; case (3): for ( c = 0 ; c < 20 ; c++ ) { printf("array[%d] = %d\n", c, array[c]); if (array[c] == -1) { break; } } printf("identify the element you wish to insert: "); scanf("%d",&temp); printf("What value do you wish to insert: "); scanf("%d",&temp2); for (c = 19; c >= temp; c-- ) { array[c] = array[c - 1]; } array[temp] = temp2; break; case (4): for ( c = 0 ; c < 20 ; c++ ) { printf("array[%d] = %d\n", c, array[c]); if (array[c] == -1) { break; } } printf("identify the element you wish to insert: "); scanf("%d",&temp); printf("What value do you wish to insert: "); scanf("%d",&temp2); for (c = 19; c >= temp+1; c-- ) { printf("test"); array[c] = array[c - 1]; } array[temp+1] = temp2; break; case (5): for ( c = 0 ; c < 20 ; c++ ) { printf("array[%d] = %d\n", c, array[c]); if (array[c] == -1) { break; } } printf("identify the element you wish to obtain: "); scanf("%d",&temp); stdOut=array[temp]; for (c = temp; c < 20; c++ ) { array[c] = array[c + 1]; if (array[c] == -1) { break; } } printf("\n\nThe number %d was removed from the list and is stored elsewhere\n\n",stdOut); break; case (6): for ( c = 0 ; c < 20 ; c++ ) { array[c]=-1; } break; case (7): flag = 0; break; } } return 0; }
Again, if there is associated code with the project, and you haven't already indicated how to run it, provide a sample run of your code:
lab46:~/src/cprog$ ./hello Hello, World! lab46:~/src/cprog$
Comments/thoughts generated through performing the project, observations made, analysis rendered, conclusions wrought. What did you learn from doing this project?
In performing this project, the following resources were referenced:
Generally, state where you got informative and useful information to help you accomplish this project when you originally worked on it (from Google, other wiki documents on the Lab46 wiki, etc.)