Write a program to print prime nums from 1-20 using c
programing?

Answer Posted / dinesh

#include<stdio.h>
main()
{
int i,j;
for(i=2;i<=20;i++)
{
c=1;
for(j=2;j<i;j++)
{
if(i%j==0)
c=0;
}
if(c==1)
printf("%d",i);
}
}

Is This Answer Correct ?    46 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can any one provide me the notes of data structure for ignou cs-62 paper

1700


How can you check to see whether a symbol is defined?

585


Explain the binary height balanced tree?

718


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

632


What is the difference between printf and scanf in c?

745






What is the difference between the expression “++a” and “a++”?

648


a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

642


When c language was developed?

633


which is an algorithm for sorting in a growing Lexicographic order

1394


Explain what is gets() function?

625


What is #include called?

565


What is the difference between array and pointer?

562


What is actual argument?

587


What is the deal on sprintf_s return value?

639


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

665