jituTechnology

jituTechnology

A program to calculate the factorial and square of given number using call by reference.

A program to calculate the factorial and square of given number using call by reference.

Codes
/*A program to calculate the factorial and square of given number using call by reference*/
/*Programed by          Jitendra Kr Yadav
                        10116
                        2Apr,2011*/
#include<stdio.h>
#include<conio.h>
void fact(int,int*,int*);
main()
{
inta,fac,sqr;
printf(“Enter the number: “);
scanf(“%d”,&a);
fact(a,&fac,&sqr);
printf(“Factorial = %d.\n”,fac);
printf(“Square = %d.\n\n”,sqr);
printf(“Press any key to continue…”);
getch();
}
void fact(intx,int*y,int*z)
{
int i;
*y=1;
*z=x*x;
for(i=1;i<=x;i++)
*y*=i;
}
Output
Enter the number: 6
Factorial = 720.
Square = 36.
Press any key to continue…

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930