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 dispaly upto 100 prime numbers(without
using Arrays,Pointer)

Answer Posted / paras patel

#include <stdio.h>
#include <conio.h>

int divide(int x ,int y)
{
while(x>y)
{
x-=y;
}

if(x==y)
{
x=0;
}
return x;

}

void main()
{
int c,i,n;
scanf("%d",&n);
clrscr();
for( i=2;i<=n;i++)
{
if(divide(n,i)==0)
{
break;
}

}
if(i!=n)
{
printf("not prime");
}
else
{
printf("prime");
}




getch();
}

Is This Answer Correct ?    16 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the scope of static variable in c?

944


Explain is it valid to address one element beyond the end of an array?

1148


What is a wrapper function in c?

1075


What is d scanf?

1027


What is actual argument?

1005


What is the purpose of main() function?

1184


Explain continue keyword in c

963


Explain the difference between getch() and getche() in c?

937


Write a program to print all permutations of a given string.

1128


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

2278


What is the difference between formatted&unformatted i/o functions?

1007


What is the difference between array_name and &array_name?

1240


What is meant by type specifiers?

1083


What functions are used for dynamic memory allocation in c language?

1077


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

2136