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

Answer Posted / rupamrox

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

Is This Answer Correct ?    9 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by a local block?

627


What is void main () in c?

722


What is static identifier?

701


Ow can I insert or delete a line (or record) in the middle of a file?

570


What is a example of a variable?

551






.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

1993


How can I automatically locate a programs configuration files in the same directory as the executable?

628


Why c is called free form language?

566


What are the key features in c programming language?

607


What is enumerated data type in c?

617


Does sprintf put null character?

596


What is spaghetti programming?

668


What is the stack in c?

714


What is an operator?

656


What is the purpose of sprintf() function?

596