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
How do you print an address?
Explain why can’t constant values be used to define an array’s initial size?
What are valid operations on pointers?
What are structure members?
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
What does c mean in basketball?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
Why is c known as a mother language?
How can you draw circles in C?
What is structure padding and packing in c?
What are Macros? What are its advantages and disadvantages?
What is the purpose of main( ) in c language?
What is the best way of making my program efficient?
What are reserved words with a programming language?
Does c have function or method?