TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Muhammad Nadeem
NA
548
66.6k
How to make more length
May 6 2016 12:50 AM
I want to make more length of this code minimum 100. please guide me how to increase my code length because I want more understanding. Thanks
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
HeavyDeciCount(9872, 9884);
}
public static void HeavyDeciCount(int x, int y)
{
var totalHeavyCount = 0;
for (int i = x; i <= y; i++)
{
var avg = i.ToString() // convert an integer to string - "9872"
.Select(o => Convert.ToInt32(o.ToString())) // convert each string character to integer - 9, 8, 7, 2
.ToArray() // create array of all integers - { 9, 8, 7, 2 }
.Average(); // calc the average of the array numbers
var isHeavy = false;
if (avg > 7)
{
isHeavy = true;
totalHeavyCount++;
}
Console.WriteLine(i + " " + avg + " " + (isHeavy ? "Yes" : "No"));
}
Console.WriteLine("Total heavy count: " + totalHeavyCount);
Console.Read();
}
}
}
Reply
Answers (
1
)
hide the progress bar in background
Error when reading the array values