write the program for prime numbers?

Answer Posted / vinay tiwari

try this u can find out all prime number between 2 and any
number entered by user .i write code in c# language but
concept remain same in any language.
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication23
{
class Program
{
static void Main(string[] args)
{
int i=2, j, rem;
while (i <= 100)
{
for (j = 2; j < i; j++)
{
rem = i % j;
if (rem == 0)
break;
}
if (i == j)
Console.WriteLine(i);
i++;
}
}
}
}

Is This Answer Correct ?    250 Yes 136 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of pointers?

592


What is the difference between union and anonymous union?

827


What is line in c preprocessor?

605


What is the use of define in c?

585


Is register a keyword in c?

623






What is action and transformation in spark?

585


What is difference between main and void main?

615


Write the control statements in C language

639


Can the “if” function be used in comparing strings?

578


What is a const pointer?

622


Explain what is the difference between null and nul?

644


what is the format specifier for printing a pointer value?

605


What are the different types of linkage exist in c?

603


The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.

1623


How many types of operators are there in c?

609