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

Answer Posted / ankur mohan sharma

#include<stdio.h>
#include<conio.h>
int main()
{
int i,n;
for(n=2;n<=20;n++)
{
for(i=2;i<n;i++)
{if(n%i==0)
break;}
}
if(i==n)
printf("\n %d",n);
return 0;

}

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is modeling?

828


What does %d do?

966


What are the scope of static variables?

846


Explain the advantages of using macro in c language?

776


`write a program to display the recomended action depends on a color of trafic light using nested if statments

1901


What is memcpy() function?

859


how can I convert a string to a number?

814


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

844


Tell me what is null pointer in c?

800


How many levels of indirection in pointers can you have in a single declaration?

847


Describe dynamic data structure in c programming language?

830


What is #define size in c?

872


What are the benefits of organizational structure?

798


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1864


When should a far pointer be used?

814