Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite each of the 5 functions below, but only using a limited form of C. The limitations are: 1. Array syntax [ ] is not

Rewrite each of the 5 functions below, but only using a limited form of C. The limitations are:

1. Array syntax [ ] is not allowed 2. You may not use the keywords "for", "while", or "do". Instead, you will use "goto" (see below) 3. The body of an "if" statement must consist of only a single "goto" statement 4. No "else" statements are allowed 5. You may not use the modulus operator %. All other arithmetic operators are allowed. Use of the assignment operator is permitted. Use of bitwise and shift operators is encouraged. ---------------- goto statements Many of you have probably never used a goto statement, although it is part of the C language. The syntax is: goto

---------------------

*/ // Problem 1. // reverse the order of the integers in x void reverse(int x[], int len) { // array syntax not allowed int i=0, j=len-1; while (i

// Problem 2. // return the maximum integer in x int max(int x[], int len) { // array syntax not allowed int answer = x[0]; // array syntax not allowed int i; for (i=1; i answer) // array syntax not allowed answer = x[i]; // if must be followed by goto // array syntax not allowed return answer; }

// Problem 3. // emulate string library's strcpy function void strcpy373(char dest[], char src[]) { // array syntax not allowed int i; for (i=0 ; src[i] != '\0'; i++) // for loops not allowed // array syntax not allowed dest[i] = src[i]; // array syntax not allowed dest[i] = '\0'; // array syntax not allowed }

// Problem 4. // return the number of odd numbers in x int count_odds(int x[ ], int len) { // array syntax not allowed int answer = 0; int i; for (i=0; i

// Problem 5. // compute x to the y power int power(int x, int y) { int answer = 1; int i; for (i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

LO3 Discuss the steps of a typical selection process.

Answered: 1 week ago