write the program for prime numbers?
Answer Posted / lavanya
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public static void prime(int number)
{
for (int i = 1; i <= number; i++)
{
for (int j = 2; j <= number; j++)
{
if (i % j == 0)
{
if(i==j)
Console.WriteLine(i.ToString());
break;
}
}
}
}
static void Main(string[] args)
{
Console.WriteLine("Enter a number");
int number = Convert.ToInt32(Console.ReadLine());
prime(number);
Console.ReadLine();
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the use of structure padding in c?
Why c is called procedure oriented language?
Do you know the difference between exit() and _exit() function in c?
Explain what are multidimensional arrays?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
i want to know the procedure of qualcomm for getting a job through offcampus
What are identifiers c?
Explain the use of fflush() function?
What are the two types of functions in c?
What is extern c used for?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
How does free() know explain how much memory to release?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is #ifdef ? What is its application?
What is function prototype in c language?