C Program Check Palindrome Number

C Program Check Palindrome Number #include <stdio.h> int main() { int n, reverseNum, lastDigit, num; printf(“Enter a number : “); scanf(“%d”,&num); n = num; reverseNum = 0; while(n > 0) { lastDigit = n % 10; reverseNum = (reverseNum * 10) + lastDigit; n = n / 10; } if(num == reverseNum) printf(“\n%d is a… Read More: C Program Check Palindrome Number »

Loading

C Program Sum Series N Natural Numbers

C Program Sum Series N Natural Numbers /* C program to calculate and print sum of the series 1+2+3+4+…+n C program to print the sum of all natural numbers from 1 to n. */ #include<stdio.h> int main() { int i,n,sum; printf(“Enter the value of n: “); scanf(“%d”,&n); sum=0; /* loop to calculate sum from 1… Read More: C Program Sum Series N Natural Numbers »

Loading

C Program Sum of One to N by Recursion

C Program Sum of One to N by Recursion /*C Program To Add all natural numbers 1 to N Using Recursion */ #include <stdio.h> /* Function prototype */ int sumNumbers(int n); /* main function */ int main() { int num; printf(“Enter a positive integer\nto add all numbers upto: “); scanf(“%d”, &num); printf(“Sum of Numbers Upto… Read More: C Program Sum of One to N by Recursion »

Loading

C Program Sum of Digits by Recursion

C Program Sum of Digits by Recursion Output: Please, Enter a number to calculate sum of digits by Recursion: 567 Using Recursion, Sum of digits of 567 = 18 C Program to calculate Sum of Digits of a given number. /** ** C program to find sum of digits using recursive function */ #include <stdio.h>… Read More: C Program Sum of Digits by Recursion »

Loading

C Program Reverse Number by Recursion

C Program Reverse Number by Recursion /* C Program Reverse Number By Recursion*/ #include <stdio.h> /* function prototype */ long reverse(long); /* main function */ int main() { long num, rev; printf(“Enter a number to be reversed by Recursion: “); scanf(“%ld”, &num); rev = reverse(num); printf(“Reverse Number = %ld\n”, rev); return 0; } long reverse(long… Read More: C Program Reverse Number by Recursion »

Loading

C Program Fibonacci Series by Recursion

C Program Fibonacci Series by Recursion Output How many terms of Fibonacci series are required? 7 Using Recursion, the Fibonacci series terms are: 0, 1, 1, 2, 3, 5, 8, ——————————– Process exited after 25.97 seconds with return value 0 Press any key to continue . . . #include<stdio.h> /* function prototype*/ int fibo(int); int… Read More: C Program Fibonacci Series by Recursion »

Loading

C Program Power By Recursion

C Program Power By Recursion Output Please Enter base: 2 Please Enter exponent: 4 2^4 = 16 ——————————– Process exited after 32.63 seconds with return value 0 Press any key to continue . . . /*************************************************** * C Program to Find N Power P using recursion * Sample Run of Recursive power function * Enter… Read More: C Program Power By Recursion »

Loading

C Program Find Factorial by Recursion

C Program Find Factorial by Recursion #include<stdio.h> // prototype for user defined recursive function long factorial(int); // main function int main() { int n; long fact; printf("Enter a number to find its factorial using Recursion="); scanf("%d", &n); if (n < 0) printf("Factorial of negative integers isn't defined.\n"); else { fact = factorial(n); printf("%d! = %ld",… Read More: C Program Find Factorial by Recursion »

Loading