 We are excited to announce that the ASP.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

# Generate 20 Floating Numbers programmatically in the following Pattern; like 12.34, 34.56, 56.78, 78.910, 910.1112, 1112.1314, RSS

## 2 replies

Last post Jun 02, 2020 03:01 AM by yij sun

• ### Generate 20 Floating Numbers programmatically in the following Pattern; like 12.34, 34.56, 56.78,...

Generate 20 Floating Numbers programmatically in the following Pattern; like 12.34, 34.56, 56.78, 78.910, 910.1112, 1112.1314, ... Please generate numbers with the starting number 12.34 and generate other numbers. Put the generated floating number into an array. Split the array into two arrays. Reverse the two arrays and print these arrays. Sum of the array elements and print the summation number. Please do not use strings and any string concatenation techniques, please generate the numbers in c#

• ### Re: Generate 20 Floating Numbers programmatically in the following Pattern; like 12.34, 34.56, 56...

Hi,

Looks like homework. IMO you'll learn more by trying (and failing which is part of the learning process) rather than by asking someone to do that for you. For a start if you look at the pattern you'll see it uses numbers from 1 to 14 and so you likey have to start with a loop to process 2 consecutive numbers and then have a formula to have them falling at their expected places.

Edit : or according to "Please generate numbers with the starting number 12.34" the next number should be generated from the previous one.

• ### Re: Generate 20 Floating Numbers programmatically in the following Pattern; like 12.34, 34.56, 56...

Jun 02, 2020 03:01 AM|yij sun|LINK

Hi myselfvinay,

Accroding to your description,as far as I think,you could calculate the number of digits for each digit.After you get these result,you could push in an array.

Just like this:

```double resultint = 0;
for (int i = 1; i < 20; i += 2)
{
if (i <= 5)
{
resultint = i * 1000 + (i + 1) * 100 + (i + 2) * 10 + (i + 3);
Console.Write(resultint / 100);
}
else if (i >= 7 && i < 9)
{
resultint = i * 10000 + (i + 1) * 1000 + (i + 2) * 100 + (i + 3);
Console.Write(Convert.ToDecimal((resultint / 1000).ToString("f3")));
}
else if (i >= 9 && i < 11)
{
resultint = i * 1000000 + (i + 1) * 10000 + (i + 2) * 100 + (i + 3);
Console.Write(resultint / 10000);
}
else
{
resultint = i * 1000000 + (i + 1) * 10000 + (i + 2) * 100 + (i + 3);
Console.Write(resultint / 10000); 