0% found this document useful (0 votes)
20 views6 pages

Pseudocode Output Analysis and Questions

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Pseudocode Output Analysis and Questions

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

What will be the output of the given pseudo code?

 Integer j
 Integer arr[2][2]= {{3, 1}, {1, 2}}
 arr[1][1]=(arr[0] [1]+arr[1] [0])+arr[0][0])
 if((arr[1][0]&arr[0] [0]&arr[1][0])<(4+arr[1][0]+2))

arr[1][0]=arr[1] [0]+arr[0][0]
 End if

arr[1][0]=(arr[1] [0]+arr[1][0])+arr[0][0]
 Print arr[1] [0]+arr[0] [0]

Note- &: bitwise AND – The bitwise AND operator (&) compares each bit of the first operand to the
corresponding bit of the second operand. If both bits are 1, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.
Options
 3.0
 12.0
 8.0
 16.0

What will be the output of the given pseudo code?


 Integer a,b,c
 Set a = 8 b = 7 c = 9
 if( (3&a) < (c ^ 3) && 9<a)

b= (a + b) &c
 if((9 – b + c) > (c + a))
 c=a^a
 End if

End if
c=c+c
 Print a+b+c

Note- &&: Logical AND – The logical AND operator (&&) returns the Boolean value true (or 1) if both operands
are true and returns false (or 0) otherwise.
&: bitwise AND – The bitwise AND operator (&) compares each bit of the first 20 operand to the corresponding
bit of the second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.
Options
 30.0
 34.0
 33.0
 43.0

What will be the output of the given pseudo code?


 Integer a,b,c
 Set a = 5 b = 3 c = 6
b =(c&b)+b
 for(each c from 2 to 4)
b = (586) ^ a
 End for
 Print a + b

Note- & bitwise AND – The bitwise AND operator (&) compares each bit of the first operand to the
corresponding bit of the second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise,
the corresponding result bit is set to 0.

^is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its
second operand. If one bit is 0 and the other bit is 1, the Corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.
Options
 24.0
 11.0
 -12.0
 6.0

What does the following pseudocode line represent?


While(temperature > 100)
Options

 Execute the loop while temperature is less than 100.

 Execute the loop while temperature is greater than 100.

 Execute the loop while temperature is equal to 100.

 Execute the loop once regardless of the temperature value

13)What is the term for a function that invokes itself?


 Self Function
 Auto Function
 Recursive Function
 Static Function

14)Which of the following is the default return value of functions in C++?


Options
 Char
 Int
 void
 Float

15)How should you position default parameters within a C++ function


prototype?
options
 To the rightmost side of the parameter list
 To the leftmost side of the parameter list
 Anywhere inside the parameter list
 Middle of the parameter list
16)How many times “A” will be printed in the following pseudocode?
 Integer a,b,c
 For(a = 0 to 4)
 For(b = 0 to 2)
 If(a is greater than b)
 Print “A”
 End for
 End for
 End If

Options
 8
 7
 9
 10

17)Which logical operator does not allow us to combine two or more


conditions?
Options
 AND
 OR
 NOT
 NAND

18)What is the term for a chart that illustrates the flow of functions or
processes without displaying any actual code?
 A fiowchart
 Structure chart
 Both A and B
 None

19)read the flowchart given below and answer the question that flows
If the fine paid for speeding was Rs 14000,which of the following could have been the speed?
Options
 128 km/hr
 136km/hr
 159 km/hr

170 km/hr

Question:
int array[] = {4, 5, 8, 9, 2);
int *ptr = (int*)(&array + 1);

What is the value of *(ptr - 1) ?

QUESTION 23 :
What is the output of the following code?

#include <stdio.h>
#include <stdint.h>
int main()
{
uint8_t a, max;

for(a=1; a<=255; a++) {


max = a;
}
printf(""max = %u"", max);
return 0;
}
A. None of the above
B. 256

C. 255

D. Infinite Loop

What will be the output of the following pseudocode?

1. Integer a,b,c
2. Set a = 6 b = 8 c = 10
3. For (each c from 2 to 4)
4. b = (2 + 5) + a
5. if ((8 + 3) < (6 + b))
6. b = b + b
7. a =10&&c
[Link]
[Link] out of the loop
[Link] if
11. a = (B + 7) + c
12. End for
13. Print a + b
a. 88
b. 74
C. 59
D.69
QUESTION 26:
What will be the output of the given pseudo code for a=2 b=7, and c=6?
[Link] funn (Integer a, Integer b, Integer c)
2 b=(c^8)+c
3 for(each c from 4 to 7)
4 b=(c+11)&b
5 a=11&a
6 End for
7 return a+b
Note- & bitwise AND- The bitwise AND operator (&) compares each bit of the first operand corresponding bit
of the second operand. If both bits are Otherwise, the corresponding result bit is set to 0. 1, the 188P
Corresponding result to the bit is set to 0.
is the bitwise exclusive OR operator that compares each bit of its second operand. If one bit is 0 and the other
bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

What will be the output of the given pseudo code?

1 Integer a,b,c
2 Set a=5, b=3, с=б
3.b-(c&b)+b
[Link](each c from 2 to 4)
5.b=(5&6)^a
6 End for
[Link] a+b

Note- & bitwise AND-The bitwise AND operator compares each bit of the first operand to the corresponding
bit of the second operand .If both bits are 1,the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.
^ Is the bitwise exclusive OR operator that compares each bit of the first operand to the corresponding bit of
its second operand. If one bit is 0 and the other bit is 1, the corresponding result bit is set to [Link], the
corresponding result bit is set to 1

Select the correct option from the given choices


a. 24.0

b. 11.0

c. -12.0

6.0

Common questions

Powered by AI

The expression `&array + 1` moves the pointer to the location just beyond the end of the array. Hence, `*(ptr - 1)` will give the last element of the array, which is `2` .

Initial a=5, b=3, c=6. Compute b=(c&b)+b=2+3=5. Loop computes b=(5&6)^5=5^5=0 from c=2 to 4, thus b remains 0. So, Print a+b=5+0=5 .

The loop executes repeatedly as long as the temperature is greater than 100 .

Default parameters should be placed to the rightmost side of the parameter list within a C++ function prototype .

The bitwise AND operator (&) compares each bit of the first operand to the corresponding bit of the second operand; both bits being 1 results in the corresponding result bit being set to 1, otherwise set to 0 .

Setting a=8, b=7, c=9: (3&a)=0, (c^3)=10. 0<10 but 9<a is false, hence b doesn't change. Then c=c+c=18. Thus, Print a+b+c gives 8+7+18=33.0 .

The loop runs a=0 to 4, b=0 to 2. 'A' prints when a > b. For each a: a=1 -> A prints for b=0. a=2 -> A prints for b=0,1. a=3 -> A prints for b=0,1,2. a=4 -> A prints b=0,1,2. This totals 8 prints of 'A' .

Initially, a=6, b=8, c=10. Loop c from 2 to 4: (inside loop, b=13). Check if (8+3)<(6+b) is true. 11<19 true. Then b=b+b=26. Set a=(b+7)+c=35. Then end of loop. Iteratively checking, ending values are a=35, b=26 .

The loop initializes a=1 and iterates till a=255, incrementally assigning max=a each time. So, the final printed value will be max=255 .

The pseudo code manipulates a 2x2 integer array and uses bitwise operations. Initially, arr[1][1] is calculated as (1+1)+3 = 5. The condition checks if (1&3&1) is less than (4+1+2), which is true since 1<7. So arr[1][0] becomes 2. Then arr[1][0] becomes (2+2)+3 = 7. Finally, it prints arr[1][0]+arr[0][0] = 7+3 = 10.0. However, this result doesn't directly align with any of the given multiple-choice options, indicating a possible error in options or misinterpretation.

You might also like