Posts

Program to find largest of three numbers using pointers

Image
// Program to find largest of three numbers using pointers #include <stdio.h> int * large ( int *a, int *b, int *c) { if (*a > *b) { if (*a > *c) { return a; } else { return c; } } else { if (*b > *c) { return b; } else { return c; } } } void main () { int x, y, z,*l; int *a, *b, *c; printf ( "\n Enter three numbers:" ); scanf ( "%d%d%d" ,&x, &y, &z); l= large (&x,&y,&z); printf ( " %d is largerest of %d, %d and %d \n" , *l , x , y , z); }   Output

Program to find the exponential series of 1+x+ x2/2! + x3/3! + ........ + xn/n! in C language

Image
Generally the expansion for the exponential series is like above. the C program for this is as below. #include <stdio.h> #include <math.h> int fact ( int f) { if (f> 1 ) return f* fact (f- 1 ); return 1 ; } void main () { int x,n,i,j; float sum= 1 ; printf ( "Enter the 'x' value:\n" ); scanf ( "%d" ,&x); printf ( "\nEnter the 'n' value:\n" ); scanf ( "%d" ,&n); for (i= 1 ;i<=n;i++) { sum=sum+( pow (x,i)/ fact (i)); } printf ( "\nSum of the series : %f " ,sum); } Output: