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
What is array of structure in c programming?
Differentiate between ordinary variable and pointer in c.
Explain the ternary tree?
What is the difference between far and near ?
Can you write the algorithm for Queue?
What is the translation phases used in c language?
Why static is used in c?
What is LINKED LIST? How can you access the last element in a linked list?
What is the difference between the local variable and global variable in c?
Can I initialize unions?
What does void main () mean?
Write a program with dynamically allocation of variable.
What does the c in ctime mean?
What are the loops in c?
Does c have function or method?