Skip to main content

WAP to find factorial of a given number

 using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace factorial
{
Class Program
{
static void main(string[] args)
{ int fact = 1, i, n;
Console.WriteLine("Input any number.");
n = Convert.Toint32(Console.ReadLine());
if( n == 0)
{
Console.WriteLine("The factorial of 0 is 1.");
Console.ReadLine();
}
else 
{
for(i=1; i<=n; i++)
{
fact = fact*i;
}
Console.WriteLine("The factorial of a given number is: {0}", fact);
Console.ReadLine();
}
}
}
}


OUTPUT:
Input any number. 
5
The factorial of a given number is: 120












Comments

Popular posts from this blog

Physical variables and transducer

unit 3 Physical Variables and transducers  Sensor Sensors are electrical devices that have the capability of sensing different physical variables. The sensor may be classified on different bases one of them is a physical quantity. Hence on the basis of a physical quantity or physical vibration involved the sensors are classified as: Resistive sensor  The input being measured is transformed into a change in resistance. examples: potentiometer, resistance thermometer, strain gauge, etc. Inductive sensor The input being measured is transformed into a change in resistance. example LVDT. Capacitive Sensor The input being measured is transformed into a change in capacitance. example: capacitive Displacement sensor. On the basis of power supply required: Active Sensor Active sensors are those which do not require an external power supply.  example: thermo-couple Passive Sensor Passive Sensors are those which require a power supply. example: Potentiometer. Physical variables and ...

Introduction To DBMS

 Database Management System  A database is an organized collection of data. A Database Management System is a collection of interrelated data and a set of programs to access those data. The main purpose of DBMS is to provide a way to store and retrieve database information that is both convenient and efficient. Management of data involves both defining structures for the storage of information and providing mechanisms for the manipulation of information. In addition, the database system must ensure safety crashes or attempts at unauthorized access. Applications of Database System Banking: For customer information, accounts, and loans, and banking transactions. Airlines: For reservations and schedule information. Airlines were among the first to use databases in a geographically distributed manner. Terminals situated around the world accessed the central database system through phone lines and other data networks. Credit card transactions: For purchase on credit cards and gener...