repetition statemens

hello..
i'm working on how you can display numbers from 11 to 100
i wrote the program but i have to display the result , 10 values per line as the following
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30.

on the screen but i dont know how to do it:D
can you help me please?

//this program will be used to display the values between 11 to 100.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
//declarations
int i=11;
while(i<=100)
{
cout<<"i="<<i;
i=i+1;
}
while(!kbhit());
}//end function main

Can i use setw? or what should i do?what is the right code for it?
i'll appreciate any help from you:)
thanks
Last edited on
An immediate thing that I notice is that you have cout<<"i=" in the loop, so when it outputs, EVERY number will have "i=" before it. Remove it to make it look cleaner.

Then, you don't have any code to output just 10 numbers per line (your problem). My approach to this would be a nested while loop within your first loop there. First, make another iterator (let's call it c). Now, make a while loop that counts from 0 to 10 (with c) and put code in that to output i and ", ". To make things on separate lines, add code after the second while loop, but before the end of the first, that outputs a newline.

BTW, you can use [ code ] [ /code ] tags (without the spaces) to format your code.
Last edited on
Please write me algorithm




Suppose a loan has a face value $1,000.00, the interest rate is 15%, and the duration is 18 months. The interest rate is computed by multiplying the face value of $1,000.00 by 0.15 to yield $150.00. This figure is then multiplied by the loan period of 1.5 years to yield $225.00 as the total interest owned. The amount is immediately deducted from the face value, leaving the consumer with only $775.00.

Repayment is made in equal monthly installment based on the face value. Hence, the monthly loan payment will be $1,000.00 divide by 18, which is $55.56. This method of calculation may not be too bad if the consumer needs $775.00 dollars, but the calculation is a bit more complicated if the customer needs $1000.00.

Write a program that will take three inputs:
- the amount the consumer needs to receive
- the interest rate
- the duration of the loan in months
The program should then calculate the face value required in order for the consumer to receive the amount needed. It should also calculate the monthly payment. Your program should allow the calculations to be repeated as often as the user wishes.
@ whiisper: Please start your own topics instead of taking over someone else's!

Also, we won't do your homework for you: http://cplusplus.com/forum/articles/1295/
closed account (D80DSL3A)
try if(i%10 == 0)cout << endl; within the while loop.
Topic archived. No new replies allowed.