Question

Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int...

Give the output of the program using Call-By-Reference:

int i, a[3];

void f (int x, int y){

x = (x*y) mod 3; y = y – x;

}

main(){

i = 0;

a[0] = 1;

a[1] = 2;

a[2] = 0;

f(i, a[i]);

print(“%d %d %d %d\n”, i, a[0], a[1], a[2]); f(a[i], a[i]);

print(“%d %d %d\n”, a[0], a[1], a[2]);

}

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Give the output of the program: void thing1(); void thing2(); int main() {      printf("3 ");...
Give the output of the program: void thing1(); void thing2(); int main() {      printf("3 "); thing1();      printf("4"); thing(2);      printf("5");      return 0; } void thing1() {      printf("Gotcha!" ); } void thing2() {      printf("HA! "); }
A.6 ... static int x = 1; int y = x * 2; void t1() {...
A.6 ... static int x = 1; int y = x * 2; void t1() {                 y++;                 cout << "x: " << x << " | y: " << y << endl;                 y += 1;                 x -= -1; } void t2() {                 int* x = &y;                 cout << "x: " << x << " | y: " << y << endl; } void t3() {                 int y = x;                 static int x...
Consider the following Java program : public static void main (string args [ ]) { int...
Consider the following Java program : public static void main (string args [ ]) { int result, x ; x = 1 ; result = 0; while (x < = 10) { if (x%2 == 0) result + = x ; + + x ; } System.out.println(result) ; } } Which of the following will be the output of the above program? A. 35 B. 30 C. 45 D. 35 2. public static void main(String args[]) { int i =...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void...
Analyze the following program and write down the output. # include <iostream> using namespace std;    void modifyArray( int [ ], int );    void modifyElement ( int );      int main( ) {   const int arraySize = 8;   int a[arraySize] = { 2, -2, 10, -3, -1 ,0, 10, -5 };      modifyArray ( a, arraySize);      for ( int i =0; i < arraySize; i++)               cout << a[i] << ‘  ’;         modifyElement ( a[4] );          for ( int i =0; i <...
describe the output that will be generated by this basic program Let x=0 FOR i =...
describe the output that will be generated by this basic program Let x=0 FOR i = 0 to 4 FOR j = 0 to i-1 LET k = (i+j-1) IF (k MOD 2=0) THEN       LET x= x+k     ELSE IF(k MOD 3 = 0) THEN     LET x=x+k-2 END IF PRINT X NEXT J NEXT I END
how can i write a function to call by reference ? using fopen, printf, fclose statements....
how can i write a function to call by reference ? using fopen, printf, fclose statements. #define _CRT_SECURE_NO_WARNINGS #define PI 3.14159 #include <stdio.h> void findArea(double *area, double r); int main(void) { double area, r = 100.5; findArea(&area, r); printf("area = %.2lf\n", area); return 0; }
2. Consider the following program written in C syntax: void swap(int a, int b) {   ...
2. Consider the following program written in C syntax: void swap(int a, int b) {    int temp;    temp = a;    a = b;    b = temp; } void main() {    int value = 2, list[5] = {1, 3, 5, 7, 9};    swap(value, list[0]);    swap(list[0], list[1]);    swap(value, list[value]); } For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three...
/************************************************************************************* Function Prototypes *************************************************************************************/ int ScanArray(char *fname, int myArray[], int nSize); void Ge
/************************************************************************************* Function Prototypes *************************************************************************************/ int ScanArray(char *fname, int myArray[], int nSize); void GenerateFromArray(void); /************************************************************************************/ /************************************************************************************/ int main(void) { /* This is the main() program. It should call the functions ScanArray() and GenerateFromArray() */ GenerateFromArray(); system("pause"); return 0; } /*************************************************************************************** Define this function to scan the elements of an array from the given data file "ArrayInp.dat". If the input file is not found, or contains invalid data, the function should return a 0 and print an error message. If the input...
When I wrote this code in the Eclipse program, I did not see a output .....
When I wrote this code in the Eclipse program, I did not see a output .. Why? ___________________ public class YClass { private int a; private int b; public void one(){ } public void two ( int x , int y ) ; a=x; b=y; } public YClass() { a=0; b=0; } } class XClass extends YClass{ private int z; public void one() { } public XClass { z=0; } } YClass Object; XClass Object;
For each of the following Python programs P and input strings I, give the output P(I),...
For each of the following Python programs P and input strings I, give the output P(I), using the formal definition of P(I) given, and employing any reasonable reference computer C: Definition of P(I), the output of a Python program. Let P be a Python program with respect to a reference computer system C. Suppose P has main function M, and let I be a string of ASCII characters that will be used as input to P. The output of P...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT