You are on page 1of 2

Abdul Ghaffar

Swen201101067

Swen (3B)

Q no=(01)

Program

#include <iostream>

using namespace std;

int square(int x){

return x*x;

int main() {

int a;

cout<<"Enter the Number:";

cin>>a;

cout<<" Square of "<<a<<" is ";

cout<<square(a);

return 0;

Out put

Enter the Number:4

Square of 4 is 16

Program

#include <iostream>
#include <conio.h>

using namespace std;

void factorial(){

int fact=1,n,i;

cin>>n;

for(i=1; i<=n; i++){

fact=fact*i;

cout<<"Factorial of "<<n<<" is: "<<fact;

int main()

cout << "Enter the number to find factorial" << endl;

void factorial();

factorial();

getch();

return 0;

Out put

Enter the number to find factorial

Factorial of 4 is: 24

You might also like