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...

read a number & print all its devisors using c-program?

Answer Posted / veluri.haritha

BETTER CODE:


void main()
{
int i,n;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
printf("\n\n The divisor's of %d are:",n);
for(i=1;i<=n/2;i++)
{
if(n%i==0)
printf(" %d ",i);
}
printf(" %d ",n);
getch();
}

This is better logic than the above program's.
For any number all factors will exit up to n/2 after n/2
only n is the factor.So, it is enough to execute the loop
for n/2 cycles . By this speed of execution increases.

EVEN BETTER LOGIC IS AVAILABLE 'U' TRY THIS...........
BY
V.HARITHA, B.TECH 1st YEAR..
student of "MADHAVI INFOTECH SOFTWARE TRAINING"
ANANTHAPUR,A.P,INDIA.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I open files mentioned on the command line, and parse option flags?

1015


What are the header files used in c language?

995


Explain how do I determine whether a character is numeric, alphabetic, and so on?

1078


What is the best way to store flag values in a program?

1010


What does the message "automatic aggregate intialization is an ansi feature" mean?

1142


What is the difference between char array and char pointer?

982


Explain how do you sort filenames in a directory?

983


What is static identifier?

1166


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1955


Write a program of advanced Fibonacci series.

1094


Difference between Function to pointer and pointer to function

1019


What are the parts of c program?

1041


What is the explanation for cyclic nature of data types in c?

1140


Explain low-order bytes.

975


What is #error and use of it?

1197