write the program for prime numbers?

Answer Posted / vijay bharti

#include<stdio.h>
#include<conio.h>

void main()
{
int num,i,count=0;
clrscr();
for(num=1;num<=300;num++)
{
for(i=2;i<=num/2;i++)
{
if(num%i!=0)
count=count+1;
}

}

printf("number of prime numbers between 1 to 300 are : %d",count);
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the c in ctime mean?

571


How many levels of pointers can you have?

706


Stimulate calculator using Switch-case-default statement for two numbers

2449


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1382


How can I direct output to the printer?

814






How pointer is different from array?

584


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3146


What are the 5 elements of structure?

569


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

5806


What are the advantages and disadvantages of c language?

563


Define the scope of static variables.

607


When should we use pointers in a c program?

634


How can I trap or ignore keyboard interrupts like control-c?

620


what is stack , heap ,code segment,and data segment

2224


What is quick sort in c?

586