English

Observe the following code. It may contain Syntax, Logical or runtime errors. int int fnWork(int p, intq) { int s = p+ b; int r= p* q; return s; return r; }

Advertisements
Advertisements

Question

Observe the following code. It may contain Syntax, Logical or runtime errors. Execute it in Java and identify the error, if any. Rewrite the code without the error. Also write the aim of the code.

int int fnWork(int p, intq)
{
    int s=p b;
    int r=p*q;
   return s;
   return r;
}
Very Short Answer
Advertisements

Solution

No error. If n is even, then return its square; else return its cube.

shaalaa.com
  Is there an error in this question or solution?
Chapter 3: User-Defined Methods - Exercises [Page 92]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 3 User-Defined Methods
Exercises | Q 7. (iv) | Page 92
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×