468,463 Members | 2,021 Online

# I don't even know where to start

Intro level problem; should be easy

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 .
Sep 18 '06 #1
7 13457
Here your aim is to print 97 asterisks in one line. So you have to start a counter and let k be the counter and initialise it by 0.

Now start a while loop with the condition that is k < 97(see your counter starts with 0).

Inside the loop print one asterisk and increment the counter. So the loop will keep on printing the asterisks for k=0,1,2,.......,96 and when the value of k will become 97 the loop terminates and you will get 97 asterisks in one line.

So give a try.
Sep 19 '06 #2
hi pukur123,i have try and it is like this........it's right....and i get the "*" print 97 times in a straight lines....
like this..
*
*
*
*
*
*
*
.
.
.
.
..
thanks ya

#include<iostream>
using namespace std;
int main()
{
int k=0;
while(k<97)
{
cout<<"*"<<endl;
k++;
}
}
Sep 19 '06 #3
Try this one....

#include<iostream>
using namespace std;
int main()
{
int k=0;
while(k<97)
{
cout<<"*\n"<<endl;
k++;
}
}
Sep 19 '06 #4
D_C
293 100+
If you want a row of 97 asterisks, instead of a column of 97 asterisks, The output statement should be cout << "*"; instead of cout << "*" << endl;
Sep 19 '06 #5
thanks,i am much clearer now..better understanding...(*_*)
Sep 20 '06 #6
Intro level problem; should be easy

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 .
hi,
i am writing a sample code for that in my standard as follows

int k;
k = 1;
while( k <= 97)
{
printf("*");
k++;
}
Sep 20 '06 #7
dush
27
int k=97;
while(k--) cout << '*';
Sep 20 '06 #8