Function alter with two parms passed by reference

Assignment Help C/C++ Programming
Reference no: EM13165822

  1. Write a function alter with two parms passed by reference: x and y. alter changes the value of x to x+y and changes the value of y to x*y. Write a main function to read in two integers, print the two integers, call the function alter using the two integers as parameters, and print the two integers again after the call to alter.
  2. Show what is printed by the following program:
       main()
       {
          char a = 'x', b = 'y';
          void func1(char,char);
          void func2(char *,char *);
          func1(a,b);
          printf("a = %c  b = %c\n",a,b);
          func2(&a,&b);
          printf("a = %c  b = %c\n",a,b);
       }
       void func1(char a, char b)
       {
          a = 'p';
          b = 'q';
       }
       void func2(char *a, char *b)
       {
          *a = 'p';
          *b = 'q';
       }
    
  3. Assume that the variables declared below are stored at the following locations. Show what value is stored as a result of each of the following statements. Assume that each statement uses the values stored by the previous statements.
       int *p, *q, *r;
       int a = 10; b = 25;
       int c[4] = {6,12,18,24};
    
       address      variables
        5000         p
        5004         q
        5008         r
        500C         a
        5010         b
        5014        c[0]
        5018        c[1]
        501C        c[2]
        5020        c[3]
    
  4. p = c;
  5. q = &a;
  6. r = p + 2;
  7. c[1] = *p;
  8. c[2] = *(p + 2);
  9. c[3] = *p + 2;
  10. *r = *q;
  11. r = q;
  12. p = &c[0];
  13. p++;

Change the following array references to equivalent pointer references:

  1. p[2]
  2. p[2]++
  3. &p[3]
  4. ++p[2]

Reference no: EM13165822

Questions Cloud

Management has asked you to create a report : Management has asked you to create a report that details how the windows 7 operating system works. describe the fundamental and generic components of the OS. discuss how the os would handel the following, process and threads, memory management, pr..
Design a nine-step counter to count : Design a nine-step counter to count in the following sequence using D flip-flops (TTL 74704) on a breadboard
Give their telephone numbers using one or more letters : People sometimes give their telephone numbers using one or more letters. write a program that accespts a 10 digit telephone number that may contain one or more letters. display the corresponding number using numerlas. the numbers and letters are a..
The state of the waiting thread to blocked : Which IPC mechanism does not change the state of the waiting thread to blocked?
Function alter with two parms passed by reference : Write a function alter with two parms passed by reference: x and y. alter changes the value of x to x+y and changes the value of y to x*y. Write a main function to read in two integers, print the two integers, call the function alter using the two..
Explores the performance consequences : This problem explores the performance consequences of having only a single level of cache in a modern processor with 40 ns DRAM column access time and a clock period of 400 ps (clock frequency 2.5 GHz). You are given the following data: A particul..
A file system stores every file under a i-node : suppose a file system stores every file under a i-node similar to (but may not be the same as) the Unix V7 File System. The i-node contains 15 addresses, each address has 32 bits (4 bytes).
Value referenced by the pointer. : Add 10 to the value referenced by pointer switch.Add 4 to the address stored in pointer switch.Subtract 5 from the value referenced by the pointer.
Create an application for disney''s cottages : Create an application for Disney's Cottages, a weekend getaway resort that rents cottages and boats to use on the local lake

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program to calculate word ladders where single-character

Write down a program in C++ to calculate word ladders where single-character substitutions have the cost of 1, and single-character additions or deletions.

  Create an employee class

Create an employee class, including two data: an employee number (type int ) and the employee's compensation (in dollars; type float). The member data should comprise an int for storing the employee number and a float for storing the employee's co..

  Prepare a linear support vector machine svm

Write a computer program to prepare a Linear Support Vector Machine SVM

  Program to next the loops in either direction

You can write your program to next the loops in either direction, that is, process row-by-row or column-by-column. Explain which way you would choose to process the data.

  Program reads a number and prints all of its binary digit

Write a program that reads a number and prints all of its binary digits. Print the remainder number % 2, thenreplace the number with number / 2. Keep going until the number is 0.

  Illustrate example from ansi c programming language

Illustrate example from ANSI C programming language, without using nested procedures, to show the fact that "assignment-by-sharing in conjunction with quasi-dynamic object binding

  Implement a simplified version of the set class

You will implement a simplified version of the set class. You must implement all functions defined in the provided file set.h. You may add other member functions and variables as necessary.

  Describe an example application of polymorphism

Provide and describe an example application of polymorphism that could be used in a program solution. List and describe the class relationships.

  Write a function that will take in an array of integers

Write a function that will take in an array of integers, sum up all the values in the array, and return the result to the calling function.

  Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

  Test a program that prompts for the user

Write and test a program that prompts for the user to input a file name and uses two functions head() and tail() - head() displays the first 10 lines of a file

  Code should include a loop that displays income

This code should include a loop that displays income generated from ticket sales for each night. Shows are performed on Thursday, Friday and Saturday nights.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd