write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)
Answer Posted / prasad avunoori
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace primeNumber
{
class Program
{
static void Main(string[] args)
{
int s=0;
int c,k;
for (int i = 2; i < 100; i++)
{
c = 0;
for (int j = 1; j <= i; j++)
{
if(i%j==0)
{
c = c + 1;
}
}
if (c == 2)
{
Console.WriteLine(i);
s++;
}
} Console.WriteLine("There are " +s);
Console.ReadLine();
}
}
}
Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
What is the purpose of main( ) in c language?
Does c have enums?
What is an array? What the different types of arrays in c?
What language is windows 1.0 written?
What is the meaning of && in c?
What is the use of f in c?
What are register variables? What are the advantage of using register variables?
How can I find out the size of a file, prior to reading it in?
Does sprintf put null character?
What functions are in conio h?
What is logical error?
Tell me the use of bit field in c language?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Not all reserved words are written in lowercase. TRUE or FALSE?
What are local static variables?