468,512 Members | 1,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

I Need Help With WHILE LOOP

NewYorker
Q1:
Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .


Q2:
Given an int variable k that has already been declared, use a while loop to print a single line consisting of 97 asterisks. Use no variables other than k .


THANK YOU IN ADVANCE
Oct 12 '06 #1
2 15748
Q1:
Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .
j=n;
while ( j > 0 )
{
cout <<"*\c";
j--;
}

Q2:
Given an int variable k that has already been declared, use a while loop to print a single line consisting of 97 asterisks. Use no variables other than k .


THANK YOU IN ADVANCE
k=97;
while ( k-- >= 0 )
cout <<"*\c";
Oct 12 '06 #2
WHAT A SUPER REPLY !!!
THANKS ALOT BOSS
j=n;
while ( j > 0 )
{
cout <<"*\c";
j--;
}


k=97;
while ( k-- >= 0 )
cout <<"*\c";
Oct 12 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Steve Henderson | last post: by
46 posts views Thread by Bruce W. Darby | last post: by
4 posts views Thread by joaotsetsemoita | last post: by
5 posts views Thread by vamsioracle | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.