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 exit() function?
What is the difference between mpi and openmp?
If I have a char * variable pointing to the name of a function ..
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
Do you know the difference between exit() and _exit() function in c?
What does do in c?
How can I write functions that take a variable number of arguments?
Why header file is used in c?
Where is c used?
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is a char c?
What is call by reference in functions?
What is %d used for?
Why do we use null pointer?
How to write c functions that modify head pointer of a linked list?