hmwk1_sol_ch - /*

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* ============================================================================ Name : Homework1.c Author : Version : Due 09.22.10 Copyright : COMPE271 Description : Homework Assignment #1 Fall 2010 ============================================================================ */ //Homework Part 1 #include <stdio.h> #include <stdlib.h> // Todo :Please note that the stack pointer's value must be within 0 and 99. // Todo :Please note that the stack pointer's value must be within 0 and 99. // Todo :Modify the function to return -1 if the value of stackPointer is not within limits int stackPointer; //stackPointer is declared, initial value is undefined char push(char *stackArray, char value) { //push instruction pushes a value onto the top of the stack //and increase the stack's size by one if(!(stackPointer <=256 && stackPointer >=0)) { //condition statement: if the stackPointer is not between 0 and 256 //exit since the stack is overflowing and print stack overflows printf( "stack overflows\n" ); return( '1') ; } else stackPointer -= 1; stackArray[stackPointer] = value; return(value); } // Todo :Please note that the stack pointer's value must be within 0...
View Full Document

Page1 / 3

hmwk1_sol_ch - /*

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online