i want to asked a question about c program the question is:

create a c program that displays all prime numbers less than
500? using looping statement

Answer Posted / vishnu nayak

int main()
{
unsigned int i,k;
unsigned int temp;
int count =0;
printf("enter the number \n");
scanf("%u",&i);
printf("\n");

for(temp =2;temp<i;temp++)
{
count =0;
for(k =2;k<=i;k++)
{
if((temp % k) == 0)
count++;

}
if(count <=1 )
printf("%u \n",temp);

}
getch();
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me is null always defined as 0(zero)?

675


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

658


What are the 4 types of organizational structures?

626


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

1481


How does free() know explain how much memory to release?

621






What is the difference between text and binary modes?

649


Explain how can I convert a number to a string?

650


Is struct oop?

583


How to find a missed value, if you want to store 100 values in a 99 sized array?

820


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4180


What is structure in c language?

620


Can static variables be declared in a header file?

619


What is void pointers in c?

591


Explain what is a static function?

633


What are the advantages of union?

628