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 is the advantage of c?

1140


Array is an lvalue or not?

1140


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1045


How would you obtain the current time and difference between two times?

1303


Is c easy to learn?

997


What are dangling pointers? How are dangling pointers different from memory leaks?

1332


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1216


Is c is a low level language?

1153


How do you write a program which produces its own source code as output?

1130


What is pointers in c?

1124


What is #ifdef ? What is its application?

1119


What are examples of structures?

1126


What is typedef struct in c?

1060


Write a program to reverse a given number in c language?

1129


Why do we need arrays in c?

1168