It is a sample c program to generate Armstrong number series from 1 to 1000.OutputProgram Source Code
//C Program to Find All Armstrong Number between 1 to 1000. #include"stdio.h" #include"conio.h" void main() { int no,r,sum=0,i; clrscr(); printf("\n\n***The Armstrong No. Series Between 1 and 1000 are:*** "); for(i=1;i<=1000;i++) { sum=0; no=i; while(no!=0) { r=no%10; no=no/10; sum=sum+(r*r*r); } if(sum==i) printf("\n%d",i); } getch(); }
Sunday, November 20, 2011
C Program to Find Armstrong Series
Labels:
armstrong,
armstrong series,
c example,
c program,
sample example
Saturday, November 19, 2011
C Program for Check Armstrong Number
It is a sample C program to find accepted number is Armstrong number on not.
Program Source Code
Output
Program Source Code
//Write a program to check accepted number is armstrong number or not. #include"stdio.h" #include"conio.h" void main() { int i,no,r,sum=0; clrscr(); printf("*******Armstrong Number******"); printf("\n Enter a number"); scanf("%d",&no); i=no; while(no!=0) { r=no%10; sum=sum+(r*r*r); no=no/10; } if(sum==i) printf("Number is a Armstrong number\n"); else printf("Number is not a armstrong number\n"); getch(); }
Output
Find Fibonacci Series Using Recursion in C Programming
It is sample C program which demonstrate how to use recursion concept in c programming. Here is a recursion program which accept a number from user and generate Fibonacci series using recursion.
Program Code
Program Code
//Find Fibonacci Series Using Recursion in C Programming #include"stdio.h" #include"conio.h" fibonacci(int n); void main() { int n,r,i; clrscr(); printf("********** Fibonacci Series Using Recursion *********\n"); printf("enter a number: "); scanf("%d",&n); printf("\n\n"); for(i=0;i<=n;i++) { r=fibonacci(i); printf("\t%d",r); } getch(); } fibonacci(int n) { int f; if((n==1)||(n==2)) return(1); else if(n==0) return(0); else f=fibonacci(n-2)+fibonacci(n-1); return(f); }Output
C Program With Recursion: Find Factorial Using Recursion in C Programming
It is a sample program example which demonstrate recursion in C programming. It is a factorial program with recursion. Accept number from the user and generate factorial of accepted number using recursion.
Program Code
Output
Program Code
#include"stdio.h" #include"conio.h" fact(int n); void main() { int n,r; clrscr(); printf("************* Find Factorial of Number Using Recursion *************"); printf("\n enter a number "); scanf("%d",&n); r=fact(n); printf("\n Factorial of %d is = %2d\t",n,r); getch(); } fact(int n) { int f; if((n==0)||(n==1)) return(1); else f=n*fact(n-1); return(f); }
Output
Labels:
c program,
c programming,
factorial,
factorial using recursion,
recursion in c,
sample c example,
sample recursion program
Subscribe to:
Posts (Atom)
Popular Posts
- PL/SQL program to generate Fibonacci series
- What is Dofollow and Nofollow Links?
- How to Format a Date in JavaScript
- Java Function Code to create Reverse Linked List of Singly Linked List (In memory pointer changes)
- jq Cli examples for power Json filtering, aggression and extraction
- Exception Handling Program in PL/SQL Oracle
- C Program For Fibonacci Series
- How to List S3 Buckets and Objects Using AWS CLI
- C Program For Floyd's Triangle
- PL/SQL Example to find average of three numbers