Preview

Woooo!

Good Essays
Open Document
Open Document
982 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Woooo!
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "dynamicArray.h"
#include <assert.h>

/* param: s the string * param: num a pointer to double * returns: true (1) if s is a number else 0 or false. * postcondition: if it is a number, num will hold * the value of the number * */ int isNumber(char *s, double *num)
{
char *end; double returnNum;

returnNum = strtod(s, &end);

/* If there's anything in end, it's not a number */ if(strcmp(end, "") == 0) { *num = returnNum; return 1; } else { return 0; }
}

/* param: stack the stack being manipulated * pre: the stack contains at least two elements * post: the top two elements are popped and * their sum is pushed back onto the stack. * */ void add (struct DynArr *stack)
{
/* FIXME: You will write this function */

double elmt1; double elmt2; double sum;

assert(!isEmptyDynArr(stack)); elmt1 = topDynArr(stack); popDynArr(stack);

assert(!isEmptyDynArr(stack)); elmt2 = topDynArr(stack); popDynArr(stack);

sum = elmt1 + elmt2; pushDynArr(stack, sum);
}

/* param: stack the stack being manipulated * pre: the stack contains at least two elements * post: the top two elements are popped and * their difference is pushed back onto the stack. * */ void subtract(struct DynArr *stack)
{
/* FIXME: You will write this function */

double elmt1; double elmt2; double subtract;

assert(!isEmptyDynArr(stack)); elmt1 = topDynArr(stack); popDynArr(stack);

assert(!isEmptyDynArr(stack)); elmt2 = topDynArr(stack); popDynArr(stack);

subtract = elmt2 - elmt1; pushDynArr(stack, subtract);

}

/* param: stack the stack being manipulated * pre: the stack contains at least two elements * post: the top two elements are popped and * their quotient is pushed back onto the stack. * */
void

You May Also Find These Documents Helpful

  • Good Essays

    To explain this, we should already know that in real life scenarios, stack increases to lower memory addresses, whenever program calls some function, the address of function call instruction is saved in stack as a return for the function. When the function executes, it allocates local variables, including buffers to stack and they are given a lower address than the return address. So, in this scenario the return address is a certain level above the base address for buffers and if the buffer is overflowing, then it is most likely that an attacker can change return address as well. If the return address is changed to some random value, then it will cause segmentation fault, but if the return address is changed to a certain address where some executable code is present, then that may complete attackers intended tasks with the application.…

    • 335 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    cout << "Select the operator you want to work (+ for addition, - for subtraction , * for multiplication , / for division):- ";…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CS 220 – Programming w/ Data Structures: You have missed one assignment and one quiz. Your instructor has extended your assignment due date to this Sunday, April 10. Your instructor has also let you to take your Quiz # 2 during his office hours during this week. Let me know if you need additional support to study for this quiz. Your grade to date in this class is 30.2/37 81.62% B.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    hallo

    • 1554 Words
    • 7 Pages

    Make a sketch that includes the following parts. Be sure to label all the parts:…

    • 1554 Words
    • 7 Pages
    Satisfactory Essays
  • Good Essays

    Hoooa

    • 450 Words
    • 2 Pages

    The first unit in a sequence.constantly ridiculed by Johnny and Frankie for being spineless. Johnny's father, Sonny Truelove (Bruce Willis), supplies his son with the marijuana from which he makes a fortune selling.…

    • 450 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    heeee

    • 1623 Words
    • 7 Pages

    This will be the buildings in which Kiddi Caru operates. It is essential for a business to have a suitable, spacious environment in which it can operate. Buildings play an important role in the image of a particular business. The image of a business can be a major factor in attracting customers to the business. A business like Kiddi Caru’s may not just want to be appealing from the outside but also from the inside.…

    • 1623 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    Hoooo

    • 6160 Words
    • 25 Pages

    The Collision Repair and Refinishing Program will create an awareness of opportunities within the vast trade areas that comprise the Collision Repair and Refinishing Industry. The program incorporates new developments and practices related to the Collision Repair and Refinishing Program…

    • 6160 Words
    • 25 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Tttttttt

    • 404 Words
    • 2 Pages

    * Our target market is to reach out to all kinds of people. We want to serve every occasional family on the lake while at night be a nice place for people to eat dinner with the nice bar scene. It will be a very out going place for couples along with families to come and have a great time.…

    • 404 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Booooooooo

    • 365 Words
    • 2 Pages

    Review the following Web sites to prepare for Discussion Question 2, performing a search using the key words hunger, poverty, and malnutrition for the first three Web sites:…

    • 365 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Yeoo

    • 1289 Words
    • 6 Pages

    |Course Title and AOS Code: HND Diploma/HNC Diploma in Health & Social Care (Care Practice) HD5HSC/HC5HSC |…

    • 1289 Words
    • 6 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Woopie

    • 389 Words
    • 2 Pages

    The Crusades were a series of holy wars launched by the Christian states of Europe against the Saracens. Back then ‘Saracen’ was a word used to describe a Moslem. In 1095 The Crusades began when Pope Claremont preached the First Crusade at the Council of Claremont. The reason for the Crusades was a war between the Moslems and the Christians. They fought for the city of Jerusalem, as the city held a Holy significance to Christian religion. They also fought for revenge for an earlier event – in 1065 Jerusalem was taken by the Turkish and about 3000 Christians were killed.…

    • 389 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Heeeey

    • 662 Words
    • 3 Pages

    Explore the ways the characters are developed in ‘Medusa’, ‘The River God’, ‘The Ruined Maid’ and ’The Clown Punk’.…

    • 662 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    kgddd;j

    • 291 Words
    • 2 Pages

    Most startups that raise money do it more than once. A typical trajectory might be (1) to get started with a few tens of thousands from something like Y Combinator or individual angels, then (2) raise a few hundred thousand to a few million to build the company, and then (3) once the company is clearly succeeding, raise one or more later rounds to accelerate growth.…

    • 291 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    frdgh

    • 900 Words
    • 4 Pages

    A physiotherapist is a health professional specialising in physical and motor development. They will assess your child and develop a plan that might include helping with head control, sitting, rolling, crawling and walking. They can also advise you on how to handle your child at home for feeding, bathing and dressing and advise on equipment that might help your child’s mobility. A…

    • 900 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Yooooo

    • 3456 Words
    • 14 Pages

    Faculty and students will be held responsible for understanding and adhering to all policies contained within the…

    • 3456 Words
    • 14 Pages
    Powerful Essays

Related Topics