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

  Write a programme on credit card number check

Credit Card Number Check. The last digit of a credit card number is the check digit, which protects againsttranscription errors such as an error in a single digit or switching two digits

  Function declare that it can throw an ioexception

Every C++ function that performs file I/O will thus need to either declare that it can throw an IOException, or contain a try-catch-finally block to deal with it. Response?

  Program that can serve as a simple calculator

Write a program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by..

  Two types of constructors

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  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.

  Main program should instantiate an instance

The main program should instantiate an instance of the class Rectangle and then make calls to the member functions to input the data and output the results

  Function named sort that takes three integer parameter

Write a function named sort that takes three integer parameters by reference. The function should rearrange the parameter values so that the first parameter gets set to the smallest value, the second parameter gets set to the second smallest value, a..

  Write program to input series of hourly temperatures

Create and write a c++ program which inputs series of 24 hourly temperatures from file, and outputs bar chart (using stars) of temperatures for the day.

  Write a recursive and iterative versions of binary search

in C++ write a recursive and iterative versions of binary search and compare their run times using the array a[i]=i, i=0,..., n-1

  Time conversion

Write a C++ program that takes an Eastern standard time in hours, minutes, and seconds,and prints it out in Central time, Mountain time, or Pacific time.

  Optimization is to add a sorting algorithm

The second optimization is to add a sorting algorithm. Each time you add an item to the array (from disk or from keyboard), you call a function called SortMyArray(), which use the bubble sorting algorithm to sort the array in the ascending order, ..

  Write a scanf statement to read in one number (int

1) Write a scanf statement to read in one number (int), and another statement to print out that number.

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