Posts

Showing posts from December, 2016

Chapter 5 : Functions & Pointers (Let us C)

Image
  (a) Write a function to calculate the factorial value of any integer entered through the keyboard // Let Us C Chapter-5:(Chapter 5 : Functions and Pointers) : Program-1 /* Write a function to calculate the factorial value of any integer entered through the keyboard */ #include<stdio.h> int N; void Fact(int); void main() { clrscr(); printf("Enter a No: "); scanf("%d",&N); if(N<0) printf("Factorial of Negative Numbers not possible\n"); else Fact(N); } void Fact(int a) { long long Fact=1; //Factorial will be large value hence used long long int temp; temp = a; while(temp>1) { Fact=Fact*temp; temp--; } printf("Factorial of %d is %lld",a,Fact); } (b) Write a function power ( a, b ), to calculate the value of a raised to b. // Let Us C Chapter-5:(Chapter 5 : Functions and Pointers) : Program-2 /* Write a function power ( a, b ), to