Private Sub Check_Click()
Dim d As Integer
Dim num As Integer
Dim s As Integer
Dim old As Integer
C Program to Find Factorial of a Number Using Pointers. This program for factorial in c allows the user to enter any integer value. Using this value, this program will find Factorial of a given number using pointers. I suggest you to refer Pointers in C article before this C factorial program example. It will help you to understand the Pointers and Pointer variable Concept. Write a c program to find largest among three numbers using binary minus operator. Write a c program to get factorial of given number. Write a c program to find out prime factor of given number. Write a c program to find out NCR factor of given number. Write a c program to print Fibonacci series of given range.
num = Val(Text1.Text)
old = num
s = 0
While num > 0
d = num Mod 10
![Write a vb program to find factorial of given numbers Write a vb program to find factorial of given numbers](http://www.softwareandfinance.com/images/VB_Fact2.png)
s = s + (d * d * d)
num = num 10
Wend
If old = s Then
Label1.Caption = 'Armstrong'
Else
Label1.Caption = 'Not armstrong'
End If
End Sub
Write a program to find Armstrong number in visual basic 6.0?
Write a c program to find Armstrong number using ifstatement?
This is not a question, it is a request for someone to do your homework. Read More
What do you need to write a program to check whether the given number is Armstrong or not?
You will need: A computer The computer language you will write in The understanding of Armstrong Numbers The number you want to find How the number is presented to the program as the input Where the output of the program should go How to put all together as a program Read More
Write a c program to find out the prime numbers between 1 to 500?
write a program to find prime number between 1 to500 Read More
Write a program in java to find the number is Adam's number or not?
Write programme for sum of number given?
write a program to find the sum of squares up to 50 Read More
Any integer is input through the keyboard write a c program to find out whether it is an odd number or even number?
any integer is input through the keyboard. write a program to find out whether it is an odd number or even number using if else statement in c#. Read More
Write a Shell program to find the smallest number from a set of numbers?
Write a c program to count number of words in a given text file and find the biggest word in that file?
Write a java program using IO String to count the number of words in a file. Read More
Write a program in Java to find factorial of a number How do you compile and execute this Java program?
How do you write a java program to find the square root of a number?
Write a Shell program to find the sum of cube of individual digits of a number?
Write a c program to find the maximum and minimum number in array?
Write a c program to find given number is prime or not?
Yes, do write, or if you're too lazy to your homework, use google. Read More
Write an assembly language program for addition of two 8 bit number?
Write a menu driven program to read two integers & find their sum, difference & product Read More
What is the largest prime no that is stored in 8 bit pattern?
Write your own prime number program and find out. Read More
Range of bits in c language?
Write a program to find second largest number in a collection of integers? Read More
Writes a c program to find the sum of all integers between 1 and n?
Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11 Read More
How do you write flowchart to find factorial of given number using recursive and non recursive?
1. flochart of cp Program to find factorial of number using function Read More
Write a program to find the sum of squares of the given number?
Algorithm and Flowcharts for a program to compute the sum of the squares of the numbers for a given range used for loop Read More
How do you write Square program using vb?
write a vb program to find the magic square Read More
Write a program to find the grade obtained by the students of a class using structure?
Write a program to find the grade obtained by the students of a class Read More
Write a C program called MonthDays to find the number of days in a given month Test your code with different input values to demonstrate that your function is robust?
Write a C program called MonthDays to find the number of days in a given month Test your code with different input values to demonstrate that your function is robust? Read More
How do you write a c program to find maximum and minimum of a set of numbers?
How do you write a c program to find maximum and minimum number in a given array? Read More
Write a program to find whether a given number is a perfect square?
:/ Just square root the number with a calculator. If it isn't 'just' a number, then its not a perfect square. Read More
How to write A Java program to print number of digits in a given number?
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String. Read More
How do you write socket program in c?
Write a c program to find whether the given number is odd or even?
I will not write a program for you submit as your homework. A integer number can checked for odd or even by looking at the low order bit. If the low order bit is 1 (true) the number is odd. The rest is up to you. Read More
To find Armstrong number in java?
/*Program to find whether given no. is Armstrong or not. Example : Input - 153 Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */ class Armstrong{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); int n = num; //use to check at last time int check=0,remainder; while(num > 0){ remainder = num % 10; check = check + (int)Math.pow(remainder,3); num = num / 10; } if(check n)… Read More
Write a c program to find eigenvalue of a matrix?
Yes, do write. That's what you always have to do when you have got a homework-program. Read More
Write a program to find out the total marks a five subject?
write a program accepts the marks of three subjects and find the total using suitable function. Read More
How do you write an assembly language program to find the sum of n numbers using array?
write an assembly language program to find sum of N numbers Read More
Write a program to find the Armstrong numbers?
/*Program to check for armstrong number */ #include<stdio.h> #include<math.h> main() { int a, b, z,x, sum = 0; printf('enter the number to check if it is armstrong numbern'); scanf('%d', &x); z=x; if ((z >= 100) && (z <= 900)) { a = z % 10; z = z / 10; b = z % 10; z = z / 10; sum = pow(a, 3) + pow(b, 3) + pow(z, 3); if (x sum) printf('a is… Read More
![Factorial Factorial](/uploads/1/2/5/6/125660085/632970164.jpg)
Write a program in c to find Armstrong number using if condition?
#include<stdio.h> #include<conio.h> #include<math.h> int armstrong(int num) { int i,c=0,arm=0; int ar[100]; for(i=0;i<100;i++) { ar[i]=0; } while(num>0) { ar[c]=num%10; c++; num/=10; } for(i=1;i<c;i++) { arm+=pow(ar[i],3); } return arm; } void main() { clrscr(); int n,a=0; printf('n Enter the number: '); scanf('%d',&n); a=armstrong(n); printf('n The number %d is',n); if(na) printf(' armstrong number'); else printf(' not an armstrong number'); getch(); } Read More
Write a c program to find simple interest?
write a program in c to calculate simple interest for 5 years Read More
Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix?
Sp[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Answer]]ell chec[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix&action=edit§ion=new|Answer it!]]k your answe[[Q/Discuss:Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Disc]][[help/answering questions|guidelin]]Spell check your answeresussionr[[help/signing in|full benefits]] Save C[[Q/Write a 8085 microprocessor program to find A inverse and A transpose… Read More
Write a c program to find the sum of digit of a given number?
for (digsum= 0; n!=0; digsum+=n%10, n/=10); Read More
Write a c program to find Volume and surface area of cube?
Write a c program to compute the surface area and volume of a cube Read More
Write a program to find odd or even number with string?
CLS PRINT 'PROGRAM: Find if number is odd/or, even' PRINT INPUT 'Enter number: ', number$ number% = VAL(number$) PRINT PRINT 'The number is '; IF number% MOD 2 = 0 THEN PRINT 'even.' ELSE PRINT 'odd.' END IF END Read More
How do you write a C program to find the GCD and LCM. write the flowchart and algorithm of the above program?
This question is not a question. You are supposed to do your homework yourself. Read More
Write program to multiply two 16 bit number using assembly language of Intel 8085?
kuldeep-great.blogspot.com check this out you find your answer ... Read More
How do you write a C program to find the remainder of a given number when it is divided by 5?
The '%' operator gives the remainder of a division, for example: b = a % 5; Read More
How to write a C program to find largest 2 numbers using pointers?
program to find maximum of two numbers using pointers Read More
Write a program to find gcd using recursive method in java?
Write a program in C to find the complex number of a given number?
There is no such thing; you seem to have misunderstood something. Any real number can be regarded as a complex number with zero imaginary part, eg.: 5 = 5+0i Read More
How do you write a java program to find the maximum number in an array?
Assume that the first number is the maximum (store it to a variable called, for example, 'maximum'). Loop through the array; every time you find an array element (a number) that is larger than the previous maximum, replace variable 'maximum' with this number. Read More
Program to find the greatest number?
How do you write a C program to find the total and average for seven subjects?
To write a C program to find the total and average for seven subjects, sum the seven subjects to get the total. Divide the total by seven to get the average. Read More
Write a C program to find the cosine and sine?
Sure, do write. The attached wikipedia-entry will help. Read More
Write a c program to find GCD of n numbers using recursion?
Is this a question? If it is, the answer is: 'yes, do write'. Read More
Factorial Program in C
It is denoted with the symbol (!). The Factorial of any number can be, product of all the numbers that are less than or equal to that number and greater than 0.
n! = n * (n-1) * (n -2) * …….* 1
n! = n * (n-1) * (n -2) * …….* 1
For example, Factorial of 5 is represented as
5! = 5 *4 * 3 * 2 * 1 = 120
5! = 5 *4 * 3 * 2 * 1 = 120
In this article, we will show you How to write a C Program to find Factorial of a Number using For Loop, While Loop, Pointers, Functions, Call by Reference and Recursion.
C Program to Find Factorial of a Number Using For Loop
This factorial program in C allows the user to enter any integer value. Using this value, this C program find Factorial of a number using For Loop.
OUTPUT:
ANALYSIS:
In this factorial program in c, we declared two integer variables i and number. We also declared one long variable Factorial and assigned a value of 1.
In this factorial program in c, we declared two integer variables i and number. We also declared one long variable Factorial and assigned a value of 1.
NOTE: Although we are calculating the C factorial of an integer variable we declared output (Factorial) as a long variable. Because, When we are calculating the factorial for large integers then the result will definitely cross the integer limit.
Below printf statement will ask the user to enter his/her own integer value to calculate the factorial
The scaf statement will assign a user entered value to the Number variable
For Loop
We initialized the integer I value to 1 and also (i <= Number) condition will help the loop to terminate when the condition fails.
We initialized the integer I value to 1 and also (i <= Number) condition will help the loop to terminate when the condition fails.
User entered integer in the above example for factorial program in c is 4
First Iteration
i = 1, Factorial = 1 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 1 *1 = 1
i++ means i will become 2
i = 1, Factorial = 1 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 1 *1 = 1
i++ means i will become 2
Second Iteration
i = 2, Factorial = 1 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 1 *2 = 2
i++ means i will become 3
i = 2, Factorial = 1 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 1 *2 = 2
i++ means i will become 3
Third Iteration
i = 3, Factorial = 2 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 2 *3 = 6
i++ means I will become 4
i = 3, Factorial = 2 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 2 *3 = 6
i++ means I will become 4
Fourth Iteration
i = 4, Factorial = 6 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 6 * 4 = 24
i++ means i will become 5 – It means (i <= Number) is Flase. So, For loop will be Terminated.
i = 4, Factorial = 6 and Number = 4 – It means (i <= Number) is True
Factorial = Factorial * i;
Factorial = 6 * 4 = 24
i++ means i will become 5 – It means (i <= Number) is Flase. So, For loop will be Terminated.
Last printf statement will print the Factorial output of the user entered integer. Within the printf statement first %d refers to Number and the second %d refers to Factorial.
Factorial of 4 = 24
C Program to Find Factorial of a Number Using While Loop
This program for factorial program in c allows you to enter any integer value. Using this value, this C program find Factorial of a number using While Loop
OUTPUT:
ANALYSIS:
We just replaced the For loop in the above factorial program in c example with the While loop. If you don’t understand the While Loop then please refer While Loop article here: While Loop
We just replaced the For loop in the above factorial program in c example with the While loop. If you don’t understand the While Loop then please refer While Loop article here: While Loop
C Program to Find Factorial of a Number Using Pointers
This program for factorial in c allows the user to enter any integer value. Using this value, this program will find Factorial of a given number using pointers.
I suggest you to refer Pointers in C article before this C factorial program example. It will help you to understand the Pointers and Pointer variable Concept.
OUTPUT:
ANALYSIS:
In this factorial program in c, we assigned the address of the Number variable to the address of the pointer variable. Here, P is the address of the pointer variable that we already declared (*P). As we all know &Number is the address of the Number.
In this factorial program in c, we assigned the address of the Number variable to the address of the pointer variable. Here, P is the address of the pointer variable that we already declared (*P). As we all know &Number is the address of the Number.
Within the For Loop, We checked i value against the pointer variable *P instead of Number variable.
Here, *P means Value inside the pointer variable
C Program to Find Factorial of a Number Using Functions
This C factorial program allows the user to enter any integer value. User entered value will be passed to the Function we created.
Within this User defined function, this C program find Factorial of a number using For Loop.
OUTPUT
ANALYSIS
In this c program to find factorial of a number example, Since the function Calculate_Factorial () will return the long value as output We assigned the function calling to long variable Factorial
In this c program to find factorial of a number example, Since the function Calculate_Factorial () will return the long value as output We assigned the function calling to long variable Factorial
When the compiler reaches to Calculate_Factorial(Number) line in main() function of a factorial program in c then the compiler will immediately jump to below function:
We already explained LOGIC in the above example.
The last line ends with return Factorial Statement. It means every time we call the Calculate_Factorial () function from the main () or any sub-functions then it will return factorial value.
C Program to Find Factorial of a Number Using Recursion
This factorial program in c allows you to enter any integer value. User entered value will be passed to the Function we created. Within this User defined function, this C program find Factorial of a number Recursively.
Please Refer Recursion in C article before this example. It will help you to understand the recursion Concept.
OUTPUT:
ANALYSIS:
Within the user-defined function of this factorial program in c,
Within the user-defined function of this factorial program in c,
If Statement will check whether the Given Number is Equal to 0 or Equal to 1
- If the condition is TRUE then the function will return 1.
- and, if the condition is TRUE then the function will return Number * (Number -1) recursively.
In this c program to find factorial of a number example, user Entered Value = 9. It means, First If statement fails So,
Factorial = Number * Calculate_Factorial (Number -1);
= 9 * Calculate_Factorial (9 -1)
= 9 * Calculate_Factorial (8)
= 9 * 8 * Calculate_Factorial (7)
= 9 * 8 * 7 * Calculate_Factorial (6)
= 9 * 8 * 7 * 6 * Calculate_Factorial (5)
= 9 * 8 * 7 * 6 * 5 * Calculate_Factorial (4)
= 9 * 8 * 7 * 6 * 5 * 4 * Calculate_Factorial (3)
= 9 * 8 * 7 * 6 * 5 * 4 * 3 * Calculate_Factorial (2)
= 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * Calculate_Factorial (1)
= 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2
= 362880
= 9 * Calculate_Factorial (9 -1)
= 9 * Calculate_Factorial (8)
= 9 * 8 * Calculate_Factorial (7)
= 9 * 8 * 7 * Calculate_Factorial (6)
= 9 * 8 * 7 * 6 * Calculate_Factorial (5)
= 9 * 8 * 7 * 6 * 5 * Calculate_Factorial (4)
= 9 * 8 * 7 * 6 * 5 * 4 * Calculate_Factorial (3)
= 9 * 8 * 7 * 6 * 5 * 4 * 3 * Calculate_Factorial (2)
= 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * Calculate_Factorial (1)
= 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2
= 362880
C Program to Find Factorial of a Number Using Call By Reference
This C factorial program allows the user to enter any integer value. Instead of User entered value, the address of the variable will be passed to the Function we created. Within this User defined function, this C program find Factorial of a number using For Loop.
Please Refer Call By Value and Call By Reference in C article before this factorial program in C example. It will help you to understand the difference between call by value and call by reference Concept.
OUTPUT:
Thank you for Visiting Our Blog