Computer Science, asked by rajpootrajanshu421, 7 months ago

The following is a method/function of some class. Give the output of the function

perform( ) when the value of ‘n’ is 6579. Show the dry run/ working.

void perform( int n )

{

int s=0, g;

while( n>0)

{

if (n%2==1)

n/=10;

g=n%10;

System.out.print(“\n g = \t” + g);

s=s+g;

n/= 5;

}

System.out.print(“\n s = \t” + s);

}​

Attachments:

Answers

Answered by daminidk
19

Explanation:

int s=0, g;

while( n>0)

{

if (n%2==1)

n/=10;

g=n%10;

System.out.print(“\n g = \t” + g);

s=s+g;

n/= 5;

}

System.out.print(“\n s = \t” + s);

}

Similar questions