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

September 2019
S M T W T F S
« Jun    
1234567
891011121314
15161718192021
22232425262728
2930