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

In C programming, what command or code can be used to determine if a number of odd or even?

611


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

649


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1770


Explain how do you print an address?

645


What are the different types of errors?

631






What is null in c?

588


Difference between goto, long jmp() and setjmp()?

693


Is stack a keyword in c?

626


What are the 5 organizational structures?

555


What language is windows 1.0 written?

563


What is structure packing in c?

593


Is c is a high level language?

609


Explain what is meant by 'bit masking'?

635


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

589


What kind of structure is a house?

546