Computer Science, asked by birendrerastogi, 6 months ago

What would be the output of the following pseudocode?
1) Integer i, j, k
2) Set k = 6
3) For (each i from 1 to 1)
4) For (each j from the value of i to 1)
5) print k+1
6) End-for
7) End-for

Answers

Answered by shubhpathaniya07
4

Answer: 7

PS C:\Users\shubh\Desktop\c++> g++ .\check.cpp

PS C:\Users\shubh\Desktop\c++> .\a.exe        

7

PS C:\Users\shubh\Desktop\c++>

Explanation:

#include <bits/stdc++.h>

using namespace std;

int main()

{   int i , j , k ;

   k=6;

for( int i=1 ; i<=1 ; i++)

{

 for( int j=i ; j<=1 ; j++)

 {

  cout<<k+1;

 }

}

return 0;

}

Answered by SaurabhJacob
1

There will be no output.

The source program for the given set of instructions is,

k=6

for i in range(1,1):

   for j in range(i,1):

print(k+1)

In the above program,

  • The input of 6 is made to the variable 'k'.
  • After that, the "for" loop is declared as start and end from the same value 1.

So it will not let the inner loop with the 'j' variable run.

Hence there will be no output for the given set of instructions.

Similar questions