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 are logical errors and how does it differ from syntax errors?
Why void is used in c?
What is static memory allocation?
Where define directive used?
How can you read a directory in a C program?
Are pointers integers in c?
What is chain pointer in c?
What does c mean?
What do you mean by Recursion Function?
What are local static variables?
Explain how can a program be made to print the name of a source file where an error occurs?
When can you use a pointer with a function?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
Is int a keyword in c?
What is the purpose of realloc()?