0
Can anyone explain me something in C#?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int num = 1; while(num < 6) { Console.WriteLine(num); num+=2; } } } }
21 Answers
+ 6
https://www.sololearn.com/learn/JavaScript/1131/
hope this help u Bogdan VÄduva
+ 6
i suggest complete java,c# like course in sololearn .. then you have some idea ..
+ 5
here at initialize time num=1.
a while check num<6 its mean when num==6 or more than that while break.
in while block a print function which print current value of num
and num increase by 2 at each while loop..
output is
1 3 5
+ 4
so why you post ur question "can anyone explain me this fuction?"
i did what u want Bogdan VÄduva
+ 2
I understood this... thanks
+ 1
and what can i do with this ? :)) i don' understand, i know this function output 1 3 5 ...
+ 1
it will print 1,3,5 on the console
+ 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
6
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int num = 0;
while(num < 6)
{
Console.WriteLine(++num);
num++;
}
}
}
}
That's what I discovered by myself when I tested different variants and I'm trying to see what results I give, with this can have the same result ... is not it good?
+ 1
i know the output of this ... 1 3 5... but I do not understand how you can apply it and why, give me examples in what you can use? or in a program?
+ 1
in frist step in line while(num<6)
num compare to 6 and checks num must smaller then 6 then enter while body and print num value then num value adds 2 and them go to first line and check again while condition and if conditon is true the previous step will repate...
+ 1
thank you for explaining, I'm sorry to say this but I already knew. I want an example, how can you apply it to a program and how it helps the program, what results in the program ... An example of a program to which this work is applied and what does it do you have?
+ 1
in programming we have some base part like loops ,condition statment, ...
in loop we can itrate on list or e.g in the real world we want bring out all of karpet in house we can not bring all of them in one time we should repate bringing out to all of them put out
like real world some times we need to repate something in programming that we use loops
+ 1
java and c # are the same? thank you...
+ 1
we can doing same thing in c# or java ways
+ 1
for example how can you compute sum of 1 to 1000? you should use loop
+ 1
int num =1;
while(num<=1000)
{
num++;
}
console.writeline(num);
0
no, with this int num = 1;
while(num < 6)
{
console.writeline(num);
num+=2;
}
with this...
and num+=2 is not num = num + 2? i know the main function ... you need this for all programs it's of the program or something like that, no? sorry for my english, i don't speak very good...
0
if you give me an example of what I need to repeat and for what I'm doing ... you're the best :))
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
6
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int num = 0;
while(num < 1000)
{
Console.WriteLine(++num);
num++;
}
}
}
}
That's what I discovered by myself when I tested different variants and I'm trying to see what results I give, with this can have the same result ... is not it good?
or change console.writeline(++num); with console.writeline(num++) and this give from 0 to 998 from first rezult 1,3,5,7....