Loops

Program for Factorial in C

Here you will get program for factorial in C. We can find factorial of any number by multiplying it with all the numbers below it. For example, factorial of 3 will be 6 (3 * 2 * 1). Program for Factorial in C #include<stdio.h> int main() { long i,n,fac=1; printf(“Enter value of n:”); scanf(“%ld”,&n); for(i=n;i>=1;–i) fac*=i;

Program for Factorial in C Read More »

Prime Number in C++

Here you learn how to check prime number in C++. Prime number is a number which is only divided by 1 or itself. Below is the C++ program to check whether a number is prime of not.   Prime Number in C++ #include<iostream> using namespace std; int main() { int n,i,flag=1; cout<<“Enter any number:”; cin>>n;

Prime Number in C++ Read More »