Posts

Showing posts with the label recursive

C program Factorial number

Factorial number - it is iterative multiplication from 1 to a given factorial number. The C program finds decimal value equivalent to given factorial number using iterative manner or for-loop . Factorial number - example calculation find decimal value for given factorial number F =6! F = 1 x 2 x 3 x 4 x 5 x 6 F = 24 x 5 x 6 F = 120 x 6 F = 720 decimal value 720 is equal to factorial 6! Factorial - C programming code The input,factorial number is read from user, while the program is running and calculate result for the factorial number using for-loop. # include <stdio.h> int main () { int x=0; printf("\n Find decimal value for given factorial number"); printf("\nEnter factorial number x :"); scanf("%d",&x); int F=1; for ( int n=1; n<=x ; n++) { F = F * n; } print...

C program Fibonacci series and Fibonacci number

This C program prints Fibonacci number series to a given number x. The Fibonacci series starts with two number 0 and 1, and then successive numbers are find by its previous two number in the series. Fibonacci series start F.series = {0,1} next number in the series F.series = {0,1,0+1} next number in the series F.series = {0,1,1,1+1} next number in the series F.series = {0,1,1,2,1+2} process continue till next number Fibonacci series - C program The C program read a integer value x from user and then prints fibonacci series numbers less than integer value x. # include <stdio.h> int main () { int x=0; int cF=0,pF=1; printf("\n print Fibonacci series"); printf("\nEnter value x :"); scanf("%d",&x); printf("\n Fibonacci Series :"); do { printf( "%d ",cF); cF= cF + pF; pF=cF-pF; ...