Find upper triangular and lower triangular matrix

    #include<conio.h> #include<stdio.h> #define s 3   void main() { int a[s][s],upper[s][s],lower[s][s]; int i,j;   clrscr();   printf("enter a %d*%d matrix :\n",s,s);   for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&a[i][j]); }   printf("upper triangular matrix is :\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) { upper[i][j]=a[i][j];...

C Program to multiplication of Matrix

    #include<stdio.h> #include<conio.h> #define s 2   void main() { int a[s][s],b[s][s]; int mul[s][s];   int i,j,k=0;   clrscr();   printf("enter 1st matrix 2*2\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&a[i][j]);   }   printf("enter 2nd matrix 2*2\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&b[i][j]);...

C Program to Subtracting Matrix

    #include<stdio.h> #include<conio.h> #define s 2   void main() { int a[s][s],b[s][s]; int add[s][s]={0,0,0,0}; int i,j;   clrscr();   printf("enter 1st matrix 2*2\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&a[i][j]);   }   printf("enter 2nd matrix 2*2\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&b[i][j]);  ...

C Programm to adding Matrix

  #include<stdio.h> #include<conio.h> #define s 2   void main() { int a[s][s],b[s][s]; int add[s][s]={0,0,0,0}; int i,j;   clrscr();   printf("enter 1st matrix 2*2\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&a[i][j]);   }   printf("enter 2nd matrix 2*2\n"); for(i=0;i<s;i++) { for(j=0;j<s;j++) scanf("%d",&b[i][j]);   }...

C PROGRAM TO REVERS GIVEN ARRAY

    #include<stdio.h> #include<conio.h> #define size 20   void main() { int i,j,a[size],rev[size]; clrscr();   printf("enter the 20 integer one by one b/w space or new line\n");   for(i=0;i<size;i++) scanf("%d",&a[i]);   for(i=0,j=size-1;i<size,j+1>0;i++,j--) { rev[i]=a[j];   }     printf("reverse of...

Simple example how to use #define in c programming

        #include<stdio.h> #include<conio.h> #define max(a,b) a>b?a:b #define min(a,b) a<b?a:b   void main() { int x,y;   clrscr();   printf("enter 1st number : "); scanf("%d",&x); printf("enter 2nd number : "); scanf("%d",&y);   printf("maximium value u entered : %d\n",max(x,y));...

C Programming – Convert decimal to binary digit

    //header file #include<stdio.h> #include<conio.h>     //main function void main() { int rem=0; int p,n; unsigned long int num,bin=0,i=1; int a[12];   clrscr();   printf("enter a number less then 1024\n"); scanf("%ld",&num);   while(num>0) { rem=num%2; bin=bin+rem*i; num=num/2; i=i*10;...

C programming – Find Roots for given quadratic equation

    #include<stdio.h> #include<conio.h> #include<math.h>   void main() { int D; int a,b,c; float r1,r2;   clrscr();   printf("a quadratic equation form is ax2+bx+c=0\n");   printf("enter the value of a = "); scanf("%d",&a);   printf("enter the value of b =...

C programming to find is given number is amicable or not?

  #include<stdio.h> #include<conio.h>   void main() {   int num1,num2,sum1=0,sum2=0; int i; clrscr();   printf("1st num : "); scanf("%d",&num1); printf("2nd num2 : "); scanf("%d",&num2);   for(i=1;i<num1;i++) {           if(num1%i==0) sum1=sum1+i; } for(i=1;i<num2;i++) {           if(num2%i==0) sum2=sum2+i; } if(sum1==num2&&sum2==num1) printf("amicable"); else printf("not amicable");...

C programming example for checking is number is perfect number or Not!!!

    #include<stdio.h> #include<conio.h> void main() { int input; int i,sum=0;   clrscr();   printf("enter a number = "); scanf("%d",&input);   for(i=1;i<input;i++) { if(input%i==0) { sum=sum+i; }   }   if(sum==input) printf("given number is perfact number"); else printf("given number is...