Hello friends
As I am a beginner of C# in .NET , I got stuck in this program
This program is about displaying prime numbers between the range of o and the number you entered.
Its running properly.But the output is not correct.
Here is my coding
using System;
using System.Collections.Generic;
using System.Text;
namespace prime
{
class Program
{
static void Main(string[] args)
{
int num;
int result;
int i, j;
Console.WriteLine("Untill what number u want to show prime number?");
num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("The prime number between o and ur number are:");
if (num == 2)
Console.WriteLine("2");
else
{
Console.WriteLine("2");
for (i = 3; i <= num; i++)
{
for (j = 2; j <=num / 2; j++)
{
result = i % j;
if (result!=0)
Console.WriteLine(i);
}
}
Console.ReadLine();
}
}
}
}
If I put 5 , it is still ok.( output shows 235)
but If I put 7 or 9 or larger number then the outputs are not correct .(out put shows 23455777)