write the program for prime numbers?

Answer Posted / ankish jaiswal

#include<stdio.h>
#include<conio.h>
int main()
{
int r,a,b,c=0;
printf("Enter the n value:");
scanf("%d",&r);
a=0;
while(a<=r)
{
b=1;c=0;
while(b<=a)
{
if(a%b==0)
c=c+1;
b++;
}
if(c==2)
printf("%d ",a);
a++;
}
getch();
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

1473


What is identifier in c?

552


What is the acronym for ansi?

636


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2747


Explain the difference between ++u and u++?

642






code for replace tabs with equivalent number of blanks

1645


Explain how can I convert a number to a string?

652


Do you know the difference between malloc() and calloc() function?

617


What is the difference between exit() and _exit() function in c?

587


where are auto variables stored? What are the characteristics of an auto variable?

597


What is assert and when would I use it?

585


write a program to print largest number of each row of a 2D array

1876


Explain how can you tell whether two strings are the same?

587


How can I find the modification date and time of a file?

606


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

819