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 sizeof () a pointer?
Why is structure important for a child?
What are the types of functions in c?
What is array of structure in c programming?
What are the 4 types of programming language?
What are the types of data types and explain?
What is typeof in c?
What is break in c?
hi send me sample aptitude papers of cts?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
Who invented b language?
What is wild pointer in c?
Write a Program to accept different goods with the number, price and date of purchase and display them
Why string is used in c?
What are header files in c programming?