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

  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    4. AND operator- combines more than one condition in a program. Makes a compunf Boolean operation.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    ● Converts the value of i to double and stores it in d. This conversion is done automatically by the compiler, because double data type is normally wider than int, there is absolutely no risk storing int in double.…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    Comp 220

    • 1463 Words
    • 6 Pages

    Pointers also have the requirement that the pointer type must be of the same data type as the variable, or the data that it points to or holds the address of. The power of pointers also hints at the potential complexity of their use, which is why this lab is focused almost entirely on several different aspects and uses of pointers. The lab also introduces pointer arrays and pointers to pointers.…

    • 1463 Words
    • 6 Pages
    Good 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

    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

    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

    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

    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
  • 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
  • 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