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 / ashwin kumar
its just to find weather given number is prime or not
#include<stdio.h>
#include<conio.h>
int main()
{
int value,i,flag=0;
clrscr();
printf("enter value to check for prime number : ");
scanf("%d",&value);
for(i=2;i<value;i++)
{
if(value%i==0)
{
flag=flag+1;
break;
}
}
if(flag==1||value==2)
printf(" %d is not a prime number",value);
else
printf(" %d is a prime number",value);
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain what is the best way to comment out a section of code that contains comments?
What is infinite loop?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
Discuss the function of conditional operator, size of operator and comma operator with examples.
What is #ifdef ? What is its application?
How do you generate random numbers in C?
Why doesn't C support function overloading?
What is structure of c program?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
Explain enumerated types.
What is keyword in c?
Explain how many levels deep can include files be nested?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
In a byte, what is the maximum decimal number that you can accommodate?
When should structures be passed by values or by references?