Please write me a program to print the first 50 prime
numbers (NOT between the range 1 -50)
Answer Posted / ankurmohansharma
#include<stdio.h>
#include<conio.h>
main()
{
int loop_counter,count_prime=1,divisor;
clrscr();
loop_counter=51; //it will exclude all less then 50
while(count_prime!=50)
{
for(divisor=2;divisor<=loop_counter-1;divisor++)
{
if (loop_counter % divisor==0)
{ break;
}
}
if(loop_counter==divisor)
{
printf("\n%d",loop_counter);
count_prime++;
}
loop_counter++;
}
getch();
}
| Is This Answer Correct ? | 8 Yes | 19 No |
Post New Answer View All Answers
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
How many loops are there in c?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
What is the difference between variable declaration and variable definition in c?
Can a pointer be static?
What is getch c?
When should the const modifier be used?
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
Explain pointer. What are function pointers in C?
How will you divide two numbers in a MACRO?
What is difference between Structure and Unions?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
What are the two types of functions in c?
Explain how do you convert strings to numbers in c?
How reliable are floating-point comparisons?