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 progam to display the factors of a given number and
disply how many prime numbers are there?

Answer Posted / sreejesh1987

//This code displays prime factors only

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,x,flag=0,d,count=0;
clrscr();
printf("\tPRIME CHECK\n");
printf("Enter a no:");
scanf("%d",&n);

for(j=2;j<n,n%j!=0;j++)
if(n-1==j)
{
printf("\n\t%d is a prime",n);

flag=1;
}

if(!flag)
{
printf("\nNumber %d is not a prime",n);
printf("\nIts factors are:\n\t");

x=2;
while(n!=1)
{

while(n%x==0)
{
n=n/x;
printf("%d ",x);
count++;
}
x++;
}
printf("\nNumber of factors:%d",count);
}
getch();
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are enumerations in C

1163


Which is better pointer or array?

1028


What is the difference between the = symbol and == symbol?

1118


how can I convert a string to a number?

1084


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

2743


What is the mean of function?

1130


What is a pointer on a pointer in c programming language?

1141


What is function definition in c?

1077


How can I remove the trailing spaces from a string?

1074


Explain what is wrong with this program statement? Void = 10;

1263


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

1035


What are the different types of data structures in c?

1166


What are runtime error?

1132


Calculate 1*2*3*____*n using recursive function??

2040


What is extern variable in c with example?

996