Write a program to print prime nums from 1-20 using c
programing?
Answer Posted / ricky dobriyal
/* hello i am ricky dobriyal software enginear*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,s;
printf("prime number 1 to 20 :\n");
for(i=1;i<=20;i++)
{
s=0;
for(j=2;j<i;j++)
{
if(i==1)
s=0;
else if(i%j==0)
s=1;
}
if(s==0)
printf("%d\t",i);
}
getch();
}
output:-1 2 3 4 7 11 13 17 19
| Is This Answer Correct ? | 18 Yes | 27 No |
Post New Answer View All Answers
Differentiate between declaring a variable and defining a variable?
Explain about C function prototype?
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
Is c procedural or object oriented?
What do you mean by keywords in c?
How does free() know explain how much memory to release?
Why void main is used in c?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
Explain logical errors? Compare with syntax errors.
The __________ attribute is used to announce variables based on definitions of columns in a table?
What is calloc in c?
How can I access an I o board directly?
What is the scope of global variable in c?
When a c file is executed there are many files that are automatically opened what are they files?