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
Is linux written in c?
Explain goto?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
What is pointer & why it is used?
What is a program?
What are the 5 data types?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
In a header file whether functions are declared or defined?
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Why is c not oop?
What is getch () for?
There seem to be a few missing operators ..
I have a varargs function which accepts a float parameter?
I need previous papers of CSC.......plz help out by posting them.......
Define and explain about ! Operator?