...
Question 3918 – Computer-Networks
May 5, 2024
Question 4430 – Communication
May 5, 2024
Question 3918 – Computer-Networks
May 5, 2024
Question 4430 – Communication
May 5, 2024

Question 7885 – Programming

Consider the following program written in pseudo-code. Assume that x and y are integers.

Count (x, y)  {
    if (y != 1)  {
        if (x != 1)  {
            print("*") ;
            Count (x/2, y) ;
        }
        else  {
             y = y - 1 ; 
             Count (1024, y) ; 
        }
    }
}

The number of times that the print statement is executed by the call Count(1024, 1024) is ______.

Correct Answer: A

Question 7 Explanation: 
#include
int count=0;
Count(x,y){
if(y!=1){
if(x!=1){
printf(“*”);
count = count +1;
Count(x/2,y);
}
else{
y=y-1;
Count(1024,y);
}
}
}

void main()
{
Count(1024,1024);
printf(“\n%d\n”,count);
}




Count ( ) is called recursively for every (y = 1023) & for every y, Count ( ) is called (x = 10) times = 1023 × 10 = 10230

A
10230
B
10231
C
10232
D
10233
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!