Want to build the ChatGPT based Apps? Start here
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
anndy smaals
2.2k
24
3.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