Does this flowchart look right? - arrays

The flowchart I'm making doesn't look right. I've looked in my textbook for examples, but they don't seem to apply to this particular assignment. The pseudocode is right, because the Java is right, but the flowchart just looks wrong.
In this assignment the program is to display an array of items (iPod, Xbox, etc.) by using an array. The program is to ask the user which items they would like to order. The user is to enter the item. The program displays "In Stock". Then the program replaces the item from the array with an empty string. The program asks the user if they would like to make another order. If the user enters in the same item, the message "Out of Stock" is displayed.If the user enters another item, the same process repeats. (While loop) Entering the the word "No" ends the program.
You can see all this in the pseudocode, I just thought writing it all out might be easier. (Or not, maybe it just took extra work reading it.)
(Click image to enlarge)

I'm no flowchart guru, but I see that you have the 2nd WHILE as a conditional diamond with the loop completely under it. How does it ever escape that loop? The flow should always come into the top of the diamond, with the exit options on either side. This means that the first WHILE is wrong too.
Also, the third WHILE only has a single exit. And the same for the IF underneath it.
For all of these test/condition diamonds the flow should come in the top and exit either side.

Related

How do I get rid of keys repeating themselves

So I am currently learning how to program in c and till now I've been making great process. I decided to make myself a matrix in which a character ('0') can be freely moved around using wasd.
Now there is the issue of keys repeating themselves making it impossible to move into two directions. Perhaps you know how if you hold a key on your keyboard it repeats itself quickly. This causes if I press for example w and a to fist go one up and then just to the left and not vertically. Is there any sort of argument that I can put in my code to prevent this (I'm using getchar())

Can anyone explain to me this LabView simulation?

I'm currently learning LabView in college and I saw this simulated there on class notes. I've been absent the day this has been asked:
I asked my friends, but no one explained well. All they said: do not forget that when the user inputs a number to the control on front panel, he needs to press outside or enter to take effect.
Can anyone explain to me in detail the function of this program from logic design and user perspective?
There is a while loop that is controlled by the "stop 2" button. Within that outer while loop is a sequence structure that contains 3 frames.
Frame 1. A while loop that continuously samples the control named "x", adds five to the value of "x" and puts the result in the indicator named "x+y". If the user presses the stop button, the program will exit the while loop and move to the next frame for execution.
Frame 2. Pause for 10000 milliseconds.
Frame 3. After the pause, a local variable reads the value of the "x" control and writes it to an indicator named "x2"
This will repeat while the "stop 2" button is in a false state.

How to draw flowchart for code involving opening from text file and reading them

like this code
fp1=fopen("Fruit.txt","r");
if(fp1==NULL)
{
printf("ERROR in opening file\n");
return 1;
}
else
{
for(i=0;i<lines;i++)//reads Fruits.txt database
{
fgets(product,sizeof(product),fp1);
id[i]=atoi(strtok(product,","));
strcpy(name[i],strtok(NULL,","));
price[i]=atof(strtok(NULL,","));
stock[i]=atoi(strtok(NULL,"\n"));
}
}
fclose(fp1);
These symbols sound too similar to differentiate their function,can anyone helps me by any method, or use names of shape according to this site http://www.breezetree.com/article-excel-flowchart-shapes.htm
REF:
Used a random online tool to generate this flowchart from your code. http://code2flow.com/
Study more about flowcharts here : http://creately.com/blog/diagrams/flowchart-guide-flowchart-tutorial/
See sample flowcharts here : http://www.conceptdraw.com/samples/flowcharts
Back in the days of FORTRAN, we used that hexagonal symbol on the page you linked to for the "DO" loop, which is basically the same as the modern "for" loop.
So, to draw the loop part of your program I would use that symbol, with a note inside like this:
for i = 0 --> (lines - 1)
Read this as "for i from 0 to (lines - 1)" with the increment of 1 implied by default.
Then the bottom-most box in the loop would have two arrows coming out of it: one straight down to the next statement, and one out the side heading back up to the side of the hexagon.
You could use the diamond to represent "if", but that can obscure the meaning of what you are trying to do, namely execute the loop a certain number of times.
BTW, I don't have high enough reputation yet to post images, so you will have to either follow the link or visualize a hexagon whose center section has been stretched horizontally.
Update: I see that, while I was typing my answer, thecbuilder has also answered this, with a real flowchart. His illustrates how the loop actually works internally, which is fine; mine was intended to show the meaning of the loop on a slightly higher level of abstraction.

Update (refresh) text-label - GTK c-language

I have developed a graphic userinterface for a small program in c. Its some kind of calculator. I have two inputfields where one can enter numbers and I want to display the result as a text-label in the same window.
I do not know how to make the window or the text-label to update itself. I am used with GUIS in java and there are a method called invalidate() to refresh the window and its child-items? Is there a similar function in the gtk3-lib in c?
I don't understand. I think there is a button to press after entering numbers in inputfields, am i right? If so, just connect a function to the button clicked signal.
This function make the sum of 2 numbers and set the label text.
If you don't have the button, i think you need to connect the signal to the inputfields, something like:
"on_spinbutton1_value_changed" : update_text_label
P.S.
I don't know C, usally i use python, but i think is quite similar.
P.P.S.
Is this the same question founded here?

How to select options based on character user input stored in an array in C?

I may have worded that strange, but if you need clarification I can provide it. I'm a complete noob to coding and am learning to use C language.
I have printed out a menu of options for the user to select. The user input is read and stored into a character array. I then printed out the string back to the user. So far everything works to this point.
My issue is selecting an option based on this character input.
I tried using strcmp inside if-else statements but never get the correct output.
Can someone point me into the right direction?

Resources