0% found this document useful (0 votes)
2 views84 pages

Pseudo Code

Uploaded by

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

Pseudo Code

Uploaded by

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

PSEUDO

CODE

2025
[Link]/@teknouf
ubk anna
TUTORIALS

2025
[Link]/@teknouf
ubk anna
General Tips:

Understand Basic Concepts: Ensure you are familiar


with basic programming concepts such as variables,
conditionals, loops, functions, and data structures.
Identify Key Operations: Recognize common
operations like arithmetic, logical, and bitwise
operations.
Break Down the Problem: Divide the pseudocode
into smaller, manageable sections and analyze each
part step by step.
Trace the Code: Use a pen and paper to trace the
code manually, keeping track of variable values at
each step.
Look for Patterns: Identify repeating patterns or
common structures in the pseudocode to simplify
the process.

2025
[Link]/@teknouf
ubk anna
Shortcut Tricks:

Simplify Arithmetic Operations:

Combine constant arithmetic operations before


running the pseudocode.
Example: a = (10 + 9) + c can be simplified to a = 19 +
c before executing.

Evaluate Conditions Early:

Evaluate conditions early to determine if a block of


code will execute.
Example: If if (x > 5) and you know x = 3, you can skip
the code inside the if block.

Use Logical Short-Circuiting:

Logical operations like AND (&&) and OR (||) can


short-circuit. If the first condition determines the
result, you can skip evaluating the second condition.
Example: if (a == 0 || b == 0) will not evaluate b == 0 if
a == 0.

2025
[Link]/@teknouf
ubk anna
Bitwise Operations Simplification:

Recognize common bitwise operation results to


simplify calculations.
Example: x & 1 checks if x is odd, and x >> 1 divides x
by 2.

Identify and Combine Loops:

If there are nested loops, try to combine or simplify


them.
Example: Instead of two nested loops iterating over a
range, consider using a single loop if possible.

Use Functions and Modular Code:

Break complex pseudocode into functions or modular


sections.
Example: Create a function for a repeated code block
to simplify understanding.
Shortcut for Increment/Decrement:

Recognize patterns in increment (i++ or ++i) and


decrement (i-- or --i) operations to predict the final
value quickly.
Example: for (i = 0; i < 10; i++) runs 10 times, making i
end at 10

2025
[Link]/@teknouf
ubk anna
Evaluate Bitwise Shifts:

Understand left (<<) and right (>>) shifts.


Left shift (x << n) multiplies x by 2^n.
Right shift (x >> n) divides x by 2^n.
Example: 20 << 2 is 20 * 4 = 80, and 20 >> 2 is 20 / 4 = 5

2025
[Link]/@teknouf
ubk anna
Example Applications:
Example 1: Simplify Arithmetic and Conditions
Pseudocode:

Integer a, b, c
Set a = 2, b = 6, c = 8
a = (10 + 9) + c
if ((c + b) > (a - c))
a=b+c
b=b+b
End if
Print a + b + c

Shortcut:

Simplify a = 19 + c to a = 27.
Evaluate condition: (8 + 6) > (27 - 8) => 14 > 19 (false).
Skip if block, a and b remain unchanged.
Calculate result: 27 + 6 + 8 = 41.

2025
[Link]/@teknouf
ubk anna
Output :-

Integer pp, qq, rr


Set pp = 0, qq = 6, rr = 7
pp = rr + pp
pp = (rr & 4) ^ rr
if ((qq & pp & rr) < (rr & qq))
if ((qq pp) < (rr + qq))
rr = (3 + 1) ^ pp
End if
End if
Print pp + qq + rr

16
18
20
22

Ans : 16

2025
[Link]/@teknouf
ubk anna
Integer p, q, r
Set p = 9, q = 6, r = 10
if ((q ^ p ^ r) > (r ^ q))
r = (11 & 12) + q
End if
if ((q ^ 6 ^ 8) > (p ^ 4))
p = (r + 3) & r
End if
Print p + q + r

35
25
37
None

Ans : 25

2025
[Link]/@teknouf
ubk anna
Integer a, b, c
Set a = 2, b = 6, c = 8
a = (10 + 9) + c
if ((c + b) > (a - c))
a=b+c
b=b+b
End if
Print a + b + c

45
41
58
None

Ans : 41

2025
[Link]/@teknouf
ubk anna
Integer a, b, c
Set a = 0, b = 2, c = 10
Integer funn (Integer a, Integer b, Integer c)
b=7+a
a = (a + c) + a
b = (b + b) + c
c=1+b
return a + b + c
End function

49
59
45
None

Ans : 59

2025
[Link]/@teknouf
ubk anna
1 Integer a, b, c

2 Set a=2, b=6, c=8

3 a=(10+9)+c

4 if((c+b)>(a-c))

5 a=b+c

6 b=b+b

7 End if

8 Print a+b+c

A. 23
B. 41
C. 48
D. 58

2025
[Link]/@teknouf
ubk anna
PRACTICE

2025
[Link]/@teknouf
ubk anna
PRACTICE

2025
[Link]/@teknouf
ubk anna
PRACTICE

2025
[Link]/@teknouf
ubk anna
PRACTICE

2025
[Link]/@teknouf
ubk anna
AFFORDABLE PLACEMENT MATERIALS

UF
O
69 X 6 = 414/- PAY ONLY
KN

299/-

TO GET 👆🏽
DM - 👇🏽
TE

[Link]/[Link]

2025
[Link]/@teknouf
ubk anna
Accenture Pseudo Questions
Answers
Q.1 ____ is used to show hierarchy in a pseudo
code.
A. indentation
B. curly braces
C. round brackets
D. semicolon
Answer: A. indentation
Q.2 Another notation for exponentiation.
a) *
b) **
c) ***
d) *^
Answer: B
Ques 3:
Integer a, b, c
Set b = 0, c = 0
for(each a from 1 to 5)
print c
b=b+1
c=c+b
end for

A. 5 4 3 2 1

B. 0 1 3 6 10

C. 2 5 8 9 10

D. 0 0 0 0 0
Answer: B
Ques 4:
Integer a, b, c
Set b = 4, c = 5
for(each a from 2 to 4)
print c
b=b-1
c=c+b
end for

A. 5 8 10

B. 1 3 6

C. 8 9 10

D. 3 6 9
Answer : A
Ques- 5
initialize char c
set c= a
print "%d",a

A. 64
B. 89
C. 97
D. Error
Answer : D
Ques : 6
#include<stdio.h>
int main ()
{
char c,a,b;
c='f';
a='s';
b='x';
int sum= c+a+b;
printf ("%d", sum);
}
A. 324
B. 320
C. 315
D. 337
Answer : D
Ques-7
#include <stdio.h>
int main()
{
int i = 0;
int x = i++, y = ++i;
printf("%d % d\n", x, y);
return 0;
}
a) 0, 2
b) 0, 1
c) 1, 2
d) Undefined
Answer : a
Ques-8
#include <stdio.h>
void main()
{
int x = 4, y, z;
y = --x;
z = x--;
printf("%d%d%d", x, y, z);
}
a) 3 2 3
b) 2 3 3
c) 3 2 2
d) 2 3 4
Answer: B
Ques-9
#include <stdio.h>
main()
{
int a=1, b=3;
b= a++ + a++ + a++ + a++ + a++;
printf("a=%d \n b=%d",a,b);
}
a) a = 6, b = 15
b) a = 1, b = 3
c) a = 1, b = 15
d) a = 2, b = 4
Answer : A
Ques-10
#include <stdio.h>
main()
{
int a=9, b=9;
a=b++;
b=a++;
b=++b;
printf("%d %d",a,b);
}
a) 9,9
b) 10,10
c) 9,10
d) 10,9
Answer : B
Ques-11
#include <stdio.h>
main()
{
int a,b;
b = 10;
a = ++b + ++b;
printf("%d%d",a,b);
}
a) 24,12
b) 23,12
c) 23,10
d) 24,10
Answer: B
Ques-12:
initialize i,n
intialize an array of size n
accept the values for the array
for i= 0 to n
arr[i] = arr[i]+arr[i+1]
end for
print the array elements
Ques-13:
void my_recursive_function(int n)
{
if(n == 0)
return;
printf("%d ",n);
my_recursive_function(n-1);
}
int main()
{
my_recursive_function(10);
return 0;
}
a) 10
b) 1
c) 10 9 8 … 1 0
d) 10 9 8 … 1
Answer : d
Ques-14 : How many times is the recursive
function called, when the following code
is executed?
void my_recursive_function(int n)
{
if(n == 0)
return;
printf("%d ",n);
my_recursive_function(n-1);
}
int main()
{
my_recursive_function(10);
return 0;
}
a) 9
b) 10
c) 11
d) 12
Answer : C
Ques 15 : Which of the following
statements is true?
a) Recursion is always better than iteration
b) Recursion uses more memory compared to iteration
c) Recursion uses less memory compared to iteration
d) Iteration is always better and simpler than recursion
Answer: b
Ques 16
Integer x = 1, y = 2, z = 3
x=y+z
z=x–y
z=z+x
z=y+z
y=y+z
Print x, y, z
A. 1 2 3
B. 4 6 8
C. 5 12 10
D. 8 6 10
Answer : C
Ques 17
Integer x = 1, y = 1 z = 1
x=y*z
z=y-z
y=z/y
Print x, y, z
A. 1 2 1
B. 1 0 0
C. 2 1 0
D. 3 4 1
Answer : B
Ques 18
#include <stdio.h>
struct School {
int age, rollNo;
};
void solve() {
struct School sc;
[Link] = 19;
[Link] = 82;
printf("%d %d", [Link], [Link]);
}
int main() {
solve();
return 0;
}
A. 19 82
B. Compilation Error
C. 82 19
D. None of the Above
Answer : A
Ques 19
#include <stdio.h>
void solve() {
int first = 10, second = 20;
int third = first + second;
{
int third = second - first;
printf("%d ", third);
}
printf("%d", third);
}
int main() {
solve();
return 0;
}
A. 10 30
B. 30 10
C. 10 20
D. 20 10
Answer : A
Ques 20
#include <stdio.h>
int main() {
int a = 3, b = 5;
int t = a;
a = b;
b = t;
printf("%d %d", a, b);
return 0;
}
A. 3 5
B. 3 3
C. 5 5
D. 5 3
Answer : D
Ques-21 What is the output of this expression,
3*1**3?
A. 27
B. 9
C. 3
D. 1
Answer : C
Ques-22 What will be the output of the
following pseudocode for arr[]= 5, 4, 3, 2, 1?
Initialize i, n
Initialize an array of size n
Take the values for the array
for i = 0 to n - 2
arr[i] = arr[i] - arr[i+1]
End for
A. 33495
B. 11111
C. 35795
D. 22222
Answer :B
Ques-23 Print the output of the following
pseudocode for x = 9, y = 7.
Integer funn(Integer x, Integer y)
Integer z
Set z = 2
y = y mod z
x = x mod z
return x + y
End function funn()
A. 2
B. 3
C. 7
D. 19
Answer : A
Ques -24
#include <stdio.h>

int main() {
int x = 10;
int y = (x++, x++, x++);
printf("%d %d\n", x, y);
return 0;
}
A. 13 12
B. 13 13
C. 10 10
D. Compliation Error
Answer :A
Ques-25
#include <stdio.h>
int main() {
int y = 0;
int x = (y != 0);
printf("%d", x);
return 0;
}
A. 0
B. 1
C. Negative Number
D. Compiler Error
Answer : A

You might also like