here is the code
Code:
/* A simple computer simulator */
#include<stdio.h>
#define SIZE 100
int main()
{
int memory[SIZE]; //simulated memory
int count = 0;
//print welcome message first
printf("\n\n");
printf("***Welcome to Simcom!***\n***Please enter your program one
instruction word at a time**\n***I will type the location number and a
question mark***\n***You then type the word for that
location***\n***Type the sentinal -99999 to stop entering your
program***\n");
do
{
printf("%02d ?",count);
scanf("%d",&memory[count]);
printf("memory%02d contains %04d\n",count,memory[count]);
count++;
}
while (count < 100 && memory[count] != -99999);
return 0;
}
problem is that it will terminate the loop after reaching 99 but not
if the sentinel is entered and i dont know why. If i use a if
statement with a break in the loop then it works fine but im not
able to put it all in the while checking any help would be helpfull.