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
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
How do you list files in a directory?
What is the difference between array and structure in c?
cavium networks written test pattern ..
Are local variables initialized to zero by default in c?
Are c and c++ the same?
What is wild pointer in c?
What are the 4 data types?
What is array of structure in c programming?
How to find a missed value, if you want to store 100 values in a 99 sized array?
Why is c known as a mother language?
What are types of structure?
What is dynamic memory allocation?
Write a program to swap two numbers without using third variable?
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?