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
anndy smaals
NA
24
4.3k
do- while loop help?
Dec 17 2018 12:49 PM
do a while loop such that if i is odd its value is doubled, and if i is even its value is incremented.
Do this while i is less that or equal to 30. Count the number of times the loop is executed and store that value in the count variable.
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int i = 1; int count = 0;
do
{
count++;
i = i;
i++;
} while (i<=30);
Console.WriteLine("The loop repeated " + count + " times and now i is " + i);
}
}
}
Reply
Answers (
1
)
passing parameters with out
a for loop problem