Monday 27 August 2018

C Program to Find Log(n) Value Using For Loop | Program for Finding Logarithm Value using For Loop |

C Program to Find Log(n) Value Using For Loop | Program for Finding Logarithm Value using For Loop |

/*C Program to Find Log(n) Value Using For Loop | Program for Finding Logarithm Value using For Loop |*/
/* Program Developed by Anupam Dutta */
#include <stdio.h>
#include <math.h>
main()
{
int num,number,i,k; //Variable declaration
printf("\nAll Values Should be a Integer\n\nFloat Number Will not be applicable\n");
printf("Enter A Value:\n"); //A integer value should be entered
scanf("%d",&num);
number=num; //Value of 'num' will be assigned to 'number'
printf("Enter A Base Value:\n"); //Enter the base value of log
scanf("%d",&k); //Scanning the entered value
for(i=1;num!=k;i++) //For Loop
{
num=num/k;
}
printf("%d",i);
printf("\n  Log Base = (%d)^(%d) = (%d)",k,number,i); //Printing the result
printf("\n  X(%d)^Y(%d) = Z(%d)",k,i,number); //Printing the result
main();
}