Quiz-1 Solution
Question:-151 Explanation
Number of bills from "Big Bazaar" or "SV Stores Number of bills from either "Big Bazaar" or "SV Stores" tell me hindi menaing of this with difference
Number of bills from "Big Bazaar" or "SV Stores"
- Hindi Meaning: "Big Bazaar" या "SV Stores" से बिलों की संख्या
- Explanation: This phrase is asking for the total count of bills specifically from either "Big Bazaar" or "SV Stores." Here, the focus is on the individual count of bills received from each store independently.
Number of bills from either "Big Bazaar" or "SV Stores"
- Hindi Meaning: "Big Bazaar" या "SV Stores" में से किसी एक से बिलों की संख्या
- Explanation: This phrase suggests counting bills from only one of the stores, either from "Big Bazaar" or from "SV Stores," not both. It implies you would consider bills from one store as the source, not taking both simultaneously.
In summary:
- The first phrase looks at bills from both stores collectively.
- The second phrase implies choosing bills from only one of the two stores.
Question:-156 Explanation
This pseudocode processes a dataset of "Words" stored in "Table 1" and moves each entry (referred to as "cards") to "Table 2" after performing specific checks. Let's break down each part:
Variables and Initial Setup
Count
: This variable is initially set to 0 and will be incremented in certain conditions, representing the final answer.Flag
: Initially set toTrue
, and it acts as a check to ensure certain conditions are met.
Main Loop
- Loop: The main
while
loop continues as long as there are cards left in "Table 1."- Read
X
from Table 1: Each card from "Table 1" is represented asX
, which has the propertiesX.Word
(the word itself) andX.LetterCount
(the total number of letters in the word).
- Read
Conditions Inside the Loop
Vowel Count Check:
- The line
if(CountVowels(X) != X.LetterCount - CountVowels(X))
:CountVowels(X)
calculates the number of vowels inX.Word
.X.LetterCount - CountVowels(X)
calculates the number of consonants inX.Word
.- This
if
condition checks if the number of vowels is not equal to the number of consonants inX.Word
. - If this condition is true (vowels ≠ consonants),
Flag
is set toFalse
.
- The line
Full Stop Check:
- The next condition checks if
X.Word
ends with a full stop ("."). - If it does and if
Flag
is stillTrue
(meaning the word passed the previous vowel/consonant check),Count
is incremented by 1. Flag
is then reset toTrue
for the next word.
- The next condition checks if
Move to Table 2: The card
X
is moved to "Table 2" before the loop processes the next card.
CountVowels
Procedure
- Purpose: This function calculates the number of vowels in a given word.
- Logic:
B
is initialized to 0 and keeps a count of vowels.- The loop iterates through each letter in
Y.Word
, and if a letter is a vowel, it incrementsB
. - Finally,
B
is returned as the total count of vowels inY.Word
.
Final Value of Count
At the end of execution, Count
represents the number of words in "Table 1" that:
- Have an equal number of vowels and consonants.
- End with a full stop ("."), ensuring that
Flag
wasTrue
.
So, Count
gives the number of words that meet these specific conditions.
what is i represeints ?
In this pseudocode,
i
is used as an index variable in the CountVowels
procedure. It represents the position of each letter in the word Y.Word
as the code loops through each letter to check if it is a vowel.Here’s how i
is used in the CountVowels
procedure:
- Initialization:
i
is set to 1 at the beginning of theCountVowels
function. - Loop Control: The
while
loop runs as long asi
is less than or equal toY.LetterCount
(the total number of letters in the word). This ensures that each letter inY.Word
is examined. - Vowel Check: Inside the loop, the condition
if(ith letter of Y.Word is a vowel)
checks whether the letter at thei
-th position is a vowel. - Increment: After each iteration,
i
is incremented by 1, moving to the next letter inY.Word
.
In summary, i
helps in traversing each character in Y.Word
to count the number of vowels.