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
Can you please explain the difference between syntax vs logical error?
Which built-in library function can be used to match a patter from the string?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
Is flag a keyword in c?
What do you understand by normalization of pointers?
"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
What is a spanning Tree?
Which one would you prefer - a macro or a function?
Can stdout be forced to print somewhere other than the screen?
What is the use of printf() and scanf() functions?
What is c programming structure?
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
What are the advantages and disadvantages of a heap?
What is pointer and structure in c?
What is operator precedence?