Friday, August 24, 2012

LOOPs

Now that we have started with Loops..

_________________________________
Keywords used in loops

for, while, repeat...until
_________________________________
Examples are :_________________________________
for( int i =1; i<=10;i=i+1)
begin
        display "Hello world"
end
_________________________________
numeric i
i=1
while(i<=10)
begin
       display "Hello World"
       i=i+1
end
_________________________________

7 comments:

Unknown said...

Q1:- Accept 10 numbers and display the sum of these numbers?

sol:- begin
numeric nNum1,nSum,nCounter
nCounter=0, nSum=0
for(nCounter=0;ncounter<10;ncounter=nCounter+1)
begin
accept nNum
nSum=nSum+nNum
end
display nSum
end

shivam agggarwal said...

good evening

Unknown said...

Where you have been assigned the task of preparing the test performance report for the candidate appering for a interview you need to find out the total number of candidate who have received the call latter based on the following condition test1 score> 75; test 2 score>75; test3 score> 75; the average score>=80

Begin
Numeric= nNum1, nNum2, nNum3, nAvg, nSelect, nReject
Character cChoice= “Y”
While (cChoice== “Y” or cChoice== “y”)
Begin
Display = “enter number of 1st test”
Accept nNum1
Display = “enter number of 2nd test”
Accept nNum2
Display = “enter number of 3rd test”
Accept nNum3
nAvg=(nNum1+nNum2+nNum3)/3
If ( nNum1>75 AND nNum2>75 AND nNum3>75 ANDnAvg>=80)
Begin
Display nSelect
nSelect= nSelect+1
End
Else
Begin
Display nReject
nReject=nReject+1
End
Display “ do you want to continue”
Accept = cChoice
End

Display nSelect
Display nReject
End



Product of 10 even numbers

Begin
Numeric =nNum1, nTotal, nProduct
nNum1 =1, nProduct = 1, ntotal = 0
for (; ;)
begin
if (nNum1 % 2 == 0 )
begin
nProduct =nProduct*nNum1
if ( nTotal < 9)
begin
nTotal =nTotal + 1
end
else
begin
break
end
end
else
begin
end
nNum = nNum + 1
end
nProduct
end

shivam agggarwal said...

Product of ten even no
Begin
Numeric =nNum1, nTotal, nProduct
nNum1 =1, nProduct = 1, ntotal = 0
for (; ;)
begin
if (nNum1 % 2 == 0 )
begin
nProduct =nProduct*nNum1
if ( nTotal < 9)
begin
nTotal =nTotal + 1
end
else
begin
break
end
end
else
begin
end
nNum = nNum + 1
end
nProduct
end


Where you have been assigned the task of preparing the test performance report for the candidate appering for a interview you need to find out the total number of candidate who have received the call latter based on the following condition test1 score> 75; test 2 score>75; test3 score> 75; the average score>=80. Write the psuedocode

Begin
Numeric= nNum1, nNum2, nNum3, nAvg, nSelect, nReject
Character cChoice= “Y”
While (cChoice== “Y” or cChoice== “y”)
Begin
Display = “enter number of 1st test”
Accept nNum1
Display = “enter number of 2nd test”
Accept nNum2
Display = “enter number of 3rd test”
Accept nNum3
nAvg=(nNum1+nNum2+nNum3)/3
If ( nNum1>75 AND nNum2>75 AND nNum3>75 ANDnAvg>=80)
Begin
Display nSelect
nSelect= nSelect+1
End
Else
Begin
Display nReject
nReject=nReject+1
End
Display “you want to continue”
Accept = cChoice
End
Display nSelect
Display nReject
End



Unknown said...

Where you have been assigned the task of preparing the test performance report for the candidate appering for a interview you need to find out the total number of candidate who have received the call latter based on the following condition test1 score> 75; test 2 score>75; test3 score> 75; the average score>=80

Begin
Numeric= nNum1, nNum2, nNum3, nAvg, nSelect, nReject
Character cChoice= “Y”
While (cChoice== “Y” or cChoice== “y”)
Begin
Display = “enter number of 1st test”
Accept nNum1
Display = “enter number of 2nd test”
Accept nNum2
Display = “enter number of 3rd test”
Accept nNum3
nAvg=(nNum1+nNum2+nNum3)/3
If ( nNum1>75 AND nNum2>75 AND nNum3>75 ANDnAvg>=80)
Begin
Display nSelect
nSelect= nSelect+1
End
Else
Begin
Display nReject
nReject=nReject+1
End
Display “ do you want to continue”
Accept = cChoice
End

Display nSelect
Display nReject
End



Product of 10 even numbers

Begin
Numeric =nNum1, nTotal, nProduct
nNum1 =1, nProduct = 1, ntotal = 0
for (; ;)
begin
if (nNum1 % 2 == 0 )
begin
nProduct =nProduct*nNum1
if ( nTotal < 9)
begin
nTotal =nTotal + 1
end
else
begin
break
end
end
else
begin
end
nNum = nNum + 1
end
nProduct
end

Unknown said...

Product of ten even no
Begin
Numeric =nNum1, nTotal, nProduct
nNum1 =1, nProduct = 1, ntotal = 0
for (; ;)
begin
if (nNum1 % 2 == 0 )
begin
nProduct =nProduct*nNum1
if ( nTotal < 9)
begin
nTotal =nTotal + 1
end
else
begin
break
end
end
else
begin
end
nNum = nNum + 1
end
nProduct
end


Where you have been assigned the task of preparing the test performance report for the candidate appering for a interview you need to find out the total number of candidate who have received the call latter based on the following condition test1 score> 75; test 2 score>75; test3 score> 75; the average score>=80. Write the psuedocode

Begin
Numeric= nNum1, nNum2, nNum3, nAvg, nSelect, nReject
Character cChoice= “Y”
While (cChoice== “Y” or cChoice== “y”)
Begin
Display = “enter number of 1st test”
Accept nNum1
Display = “enter number of 2nd test”
Accept nNum2
Display = “enter number of 3rd test”
Accept nNum3
nAvg=(nNum1+nNum2+nNum3)/3
If ( nNum1>75 AND nNum2>75 AND nNum3>75 ANDnAvg>=80)
Begin
Display nSelect
nSelect= nSelect+1
End
Else
Begin
Display nReject
nReject=nReject+1
End
Display “you want to continue”
Accept = cChoice
End
Display nSelect
Display nReject
End

Unknown said...

Product of ten even no
Begin
Numeric =nNum1, nTotal, nProduct
nNum1 =1, nProduct = 1, ntotal = 0
for (; ;)
begin
if (nNum1 % 2 == 0 )
begin
nProduct =nProduct*nNum1
if ( nTotal < 9)
begin
nTotal =nTotal + 1
end
else
begin
break
end
end
else
begin
end
nNum = nNum + 1
end
nProduct
end


Where you have been assigned the task of preparing the test performance report for the candidate appering for a interview you need to find out the total number of candidate who have received the call latter based on the following condition test1 score> 75; test 2 score>75; test3 score> 75; the average score>=80. Write the psuedocode

Begin
Numeric= nNum1, nNum2, nNum3, nAvg, nSelect, nReject
Character cChoice= “Y”
While (cChoice== “Y” or cChoice== “y”)
Begin
Display = “enter number of 1st test”
Accept nNum1
Display = “enter number of 2nd test”
Accept nNum2
Display = “enter number of 3rd test”
Accept nNum3
nAvg=(nNum1+nNum2+nNum3)/3
If ( nNum1>75 AND nNum2>75 AND nNum3>75 ANDnAvg>=80)
Begin
Display nSelect
nSelect= nSelect+1
End
Else
Begin
Display nReject
nReject=nReject+1
End
Display “you want to continue”
Accept = cChoice
End
Display nSelect
Display nReject
End