Write a program to print the prime numbers from 1 to 100?
Answer Posted / prth
#include<stdio.h>
#include<conio.h>
void main()
{
int flag,x;
clrscr();
printf("1\t");
for(int i=1;i<=100;i++)
{
flag=0;
for(x=2;x<=i;x++)
{
if(i%x==0)
{
flag=1;
break;
}
else
continue;
}
if(i==x)
printf("%d\t",i);
}
getch();
}
| Is This Answer Correct ? | 48 Yes | 11 No |
Post New Answer View All Answers
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
please explain every phase in the "SDLC" in the dotnet.
Is c easy to learn?
Are there constructors in c?
What is the 'named constructor idiom'?
How can I automatically locate a programs configuration files in the same directory as the executable?
Explain what is the benefit of using #define to declare a constant?
Explain how do you determine the length of a string value that was stored in a variable?
What extern c means?
What is the use of function in c?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
What are the key features in c programming language?
Explain what is meant by high-order and low-order bytes?
Why n++ execute faster than n+1 ?