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


Please Help Members By Posting Answers For Below Questions

Can you please explain the difference between syntax vs logical error?

705


Which built-in library function can be used to match a patter from the string?

755


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1194


Is flag a keyword in c?

692


What do you understand by normalization of pointers?

635






"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

666


What is a spanning Tree?

973


Which one would you prefer - a macro or a function?

613


Can stdout be forced to print somewhere other than the screen?

631


What is the use of printf() and scanf() functions?

642


What is c programming structure?

631


Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol

674


What are the advantages and disadvantages of a heap?

718


What is pointer and structure in c?

583


What is operator precedence?

653