| This displays numbers from 0 to 25...i was wondering what i could use to not display numbers 10 through 15...which means i want to display numbers from 0 to 25 except numbers from 10 to 15.....any help static void Main() { for(int j = 0; j<26; j++)Console.WriteLine("Number {0}", j); Console.WriteLine("Press enter to continue"); Console.ReadLine(); } } |

Displaying Numbers
yanivoroz
using
System;class
Math{
static void Main(){
for (int j = 0; j < 26; j++){
if (!(j >= 10 && j <= 15)){
Console.WriteLine("Number {0}", j);
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
}
}
}
this gives an output of Number 0.......
pena_a
int[] values = {1,2,3,4,5,6,7,8,9,15,16,17,18,19,20,21,22,23,24,25};
foreach(int count in values){
Console.WriteLine("Number {0}", count);}
Console.WriteLine("Press enter to continue");
Console.ReadLine();
Whitey
How about this one
int
[] values = {1,2,3,4,5,6,7,8,9,15,16,17,18,19,20,21,22,23,24,25}; foreach(int count in values){
if(count < 10 || count > 15){
Console.WriteLine("Number {0}", count);
}
}
Console.WriteLine("Press enter to continue");
Console.ReadLine();
CSFDeveloper
tirengarfio
Use a if statement:
for
(int j = 0; j < 26; j++){
if (!(j >= 10 && j <= 15)){
Console.WriteLine("Number {0}", j); Console.WriteLine("Press enter to continue"); Console.ReadLine();}
}
Regards,
Vikram
Brent-GPTX
Maybe my solution looks like previous posted message.But it will be beneficial for you.(usage of "if" statement).
static void Main(string[] args)
{
for(int count = 0;count <26; count ++)
{
if(count < 10 || count > 15)
{
Console.WriteLine("Number {0}", count);
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
}
}
Cheers =)
Marie
ramos_490
static void Main()
{
for (int j = 0; j < 26; j++){
if ((j >= 10 && j <= 15)){
Console.WriteLine("Number {0}", j);
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
}
}
}
Bochur
for
(int j = 0; j < 26; j++){
if (!(j >= 10 && j <= 15)){
Console.WriteLine("Number {0}", j);}
}
Console.WriteLine("Press enter to continue"); Console.ReadLine();Regards,
Vikram
JohnDaldry
You did not notice the Not Operator(!) in my code
See the if statement in detail once again: if ( ! (j >= 10 && j <= 15))
I have made the ! operator big in size now. In fact if you had copy-pasted the earlier code it would have worked.
Regards,
Vikram
ZhuangYicheng