Computer Science: A Structured Programming Approach Using C, Third Edition
Computer Science: A Structured Programming Approach Using C, Third Edition
3rd Edition
ISBN: 9780534491321
Author: Behrouz A. Forouzan, Richard F. Gilberg
Publisher: Course Technology, Inc.
Expert Solution & Answer
Book Icon
Chapter 4, Problem 26PS

Explanation of Solution

Given: The user passes 3, 5, 4, 6 as inputs in the following program:

#include

//Function Declarations

int strange(int x, int y);

int main(void)

{

//Local Declarations

int a;

int b;

int c;

int d;

int r;

int s;

int t;

int u;

int v;

//Statements

scanf("%d %d %d %d", &a, &b, &c, &d);

r=strange(a,b);

s=strange(r,c);

t=strange(strange(s,d), strange(4,2));

u=strange(t+3, s+2);

v=strange(strange(strange(u, a), b),c);

printf("%d %d %d %d %d", r, s, t, u, v);

return 0;

}//main

// = = = = = = = = = = strange = = = = = = = = = = =

int strange(int x, int y)

{

//Local Declarations

int t;

int z;

//Statements

t=x+y;

z=x*y;

return (t+z);

} //strange

To find: The output of the aforementioned program for the given inputs, 3, 5, 4, and 6.

Solution:

The aforementioned program will display the following output:

23 119 12599 1537565 184507919

The following are the descriptions for determining the output:

In the above program, firstly, the header file is included, and then the function, strange, is declared, which has two integer parameters...

Blurred answer
Students have asked these similar questions
In C++,  Given the following function prototype: void testDefault(int a, int b = 7, char z = '*'); Indicate if each of the following function calls are valid or invalid a) testDefault(5); b) testDefault(); c) testDefault(6, '#'); d) testDefault(0, 0, '?');
What is the output of the following code? // CPP program to illustrate// working of Virtual Functions#include <iostream>using namespace std; class base {public:void fun_1() { cout << "base-1\n"; }virtual void fun_2() { cout << "base-2\n"; }virtual void fun_3() { cout << "base-3\n"; }virtual void fun_4() { cout << "base-4\n"; }}; class derived : public base {public:void fun_1() { cout << "derived-1\n"; }void fun_2() { cout << "derived-2\n"; }void fun_4(int x) { cout << "derived-4\n"; }}; int main(){base* p;derived obj1;p = &obj1; // Early binding because fun1() is non-virtual// in basep->fun_1(); // Late binding (RTP)p->fun_2(); // Late binding (RTP)p->fun_3(); // Late binding (RTP)p->fun_4(); // Early binding but this function call is// illegal(produces error) because pointer// is of base type and function is of// derived class// p->fun_4(5);}
Implement in C Programming 6.10.2: Pass by pointer. Write a function call to ConvertMoney() to store the number of quarters, nickels, and pennies within the integer variables numQuarters, numNickels, and numPennies, respectively. Ex: If the input is 133, then the output is: Quarters: 5 Nickels: 1 Pennies: 3 #include <stdio.h> void ConvertMoney(int totalPennies, int* numQuarters, int* numNickels, int* numPennies) {   *numQuarters = totalPennies / 25;   totalPennies = totalPennies % 25;      *numNickels = totalPennies / 5;   totalPennies = totalPennies % 5;      *numPennies = totalPennies;} int main(void) {   int totalPennies;   int numQuarters;   int numNickels;   int numPennies;    scanf("%d", &totalPennies);      /* Your code goes here */      printf("Quarters: %d\n", numQuarters);   printf("Nickels: %d\n", numNickels);   printf("Pennies: %d\n", numPennies);      return 0;}

Chapter 4 Solutions

Computer Science: A Structured Programming Approach Using C, Third Edition

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning