Posts

Finding Factorial Of a Number using C

  #include <stdio.h> #include <stdlib.h> int fact ( int n ); int main (){ int n ; printf ( "Enter the Digit:" ); scanf ( " %d " , & n ); int x = fact ( n ); } int fact ( int n ) { int i = 1 ; int fact = fact * n ; return fact ; }

C Program to check Armstrong Number or Not

#include <stdio.h> #include <stdlib.h> #include <math.h> void main () { system ( "clear" ); int x , y , sum = 0 , n ; printf ( "Enter The no : " ); scanf ( " %d " , & x ); n = x ; while ( x > 0 ) { y = x % 10 ; sum = sum + pow ( y , 3 ); x = x / 10 ; } if ( n == sum ){ printf ( "Armstrong Number. \n " );} else printf ( "Not Armstrong No \n " ); }

C Program to find Amicable Number

#include <stdio.h>   #include <stdlib.h> int main () { system ( "clear" ); int num_1,num_2,sum = 0 ; printf ( "Enter Number One :" ); scanf ( " %d " , & num_1); printf ( "Enter Number Two :" ); scanf ( " %d " , & num_2); for ( int i = 1 ;i < num_1;i ++ ) { if (num_1 % i == 0 ) { sum = sum + i; } } if (sum == num_2) printf ( "Amicable Number \n " ); else printf ( "Not Amicable Number \n " ); }

C Programme for Newton's Forward Interpolation Formula

#include <stdio.h> #include <stdlib.h> int fact ( int n ) { if ( n == 0 ) return 1 ; else return n * fact ( n - 1 ); } int main () { int n , i , r , j ; float c ; system ( "clear" ); printf ( "Enter number of rows in the table: " ); scanf ( " %d " , & n ); float x [ n ], y [ n ]; printf ( "Enter the values of x and y in the table: \n " ); for ( i = 0 ; i < n ; i ++ ) { printf ( "x[ %d ]:" , i + 1 ); scanf ( " %f " , & x [ i ]); printf ( "y[ %d ]:" , i + 1 ); scanf ( " %f " , & y [ i ]); } do { printf ( "Enter value of x at which u want to find y: " ); scanf ( " %f " , & c ); float h = x [ 1 ] - x [ 0 ]; float u = ( c - x [ 0 ]) / h ; int t = n - 1 ; float k [ t ]; int s [ n - 1 ]; s [ 0 ] = k [ 0 ]; ...