Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Differentiate between declaring a variable and defining a variable?

1032


Explain about C function prototype?

1079


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

1101


Is c procedural or object oriented?

999


What do you mean by keywords in c?

1141


How does free() know explain how much memory to release?

1052


Why void main is used in c?

1044


#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??

1949


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

1109


Explain logical errors? Compare with syntax errors.

1068


The __________ attribute is used to announce variables based on definitions of columns in a table?

1196


What is calloc in c?

1139


How can I access an I o board directly?

1089


What is the scope of global variable in c?

986


When a c file is executed there are many files that are automatically opened what are they files?

1103