Git Product home page Git Product logo

assignment7's Introduction

Assignment7

Objectives

To gain an understanding of pointers.

Part 1

  1. In a program reverse.c, write a string reversal function using pointers that takes only a string as input, creates 2 pointers, performs a string reversal using those pointers, and prints out the reversed string. Your driver should take a string input by the user using fgets().

Part 2

In a text file assignment7.txt, answer the following questions:

  1. Explain the difference between ++*p, *p++ and *++p, if there is any.
  2. Is the left to right or right to left order guaranteed for operator precedence?
  3. What are the advantages of using pointers?
  4. Consider a C program’s main() function that starts as follows:
    int main(int argc, char **argv) {
      int a[10] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
      int *p = a + 2;
      char *str = "hello";
  • For integer expressions (i.e., the expressions whose types are char, short, int, size_t, long, or long long--either signed or unsigned), write the actual number value.

  • For non-integer expressions, write the type name, in the format that you use to declare a variable of that type. Some example type names include but are not limited to:

      int *
      double
      double **
      int(*)(int)
  • Write "invalid" if a given expression is not a valid C expression.

  • Make sure sure to explain each of your answers.

4.1 "abc"
4.2 "xyz"[1] - ’y’
4.3 ’\0’ == 0
4.4 *a
4.5 &a[0]
4.6 *p
4.7 &p
4.8 *++argv
4.9 &main
4.10 sizeof(str)

Part 3:

Submit your final project proposal in the "Final Project" Repository.

Submission Guidelines

Please include your name and a description in a comment at the top of your code files. Please also include your name at the top of your assignment7.txt file.

All files must be submitted via GitHub by 10:00am 7/11.

assignment7's People

Contributors

clesleycode avatar mnd2126 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.