SlideShare a Scribd company logo
Simple C Program :
Program :
/* Simple C Program .
Creation Date : 12:34 PM 07/11/2010
Author : R.K.Singh*/
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
printf("n My first program in C !");
getch();
}
Output :
My first program in C !_
Program to print value of existing
number :
Program :
/* Program to print value of existing number .
Creation Date : 12:38 PM 07/11/2010
Author :R.K.Singh */
#include <stdio.h>
#include <conio.h>
void main()
{
int no = 19;
clrscr();
printf("n Number is : %d",no);
getch();
}
Output :
Number is : 19 !_
Program to demonstrate scanf()
and printf() : 3.C :
Program :
/* Program to demonstrate scanf() and printf().
Creation Date : 12:41 PM 07/11/2011
Author : R.K.Singh */
#include <stdio.h>
#include <conio.h>
void main()
{
int no;
clrscr();
printf("n Enter any number :");
scanf("%d",&no);
printf("n Number is : %d",no);
getch();
}
Output :
Enter any number :12
Number is : 12_
Operators
Program to calculate addition of two
numbers :
Program :
/* Program to calculate addition of two numbers.
Creation Date : 09:51 PM 21/11/2011
Author : R.K.Singh */
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
clrscr();
printf("n Enter any 2 numbers : ");
scanf("%d %d",&a,&b);
c = a + b;
printf("n Addition is : %d",c);
getch();
}
Output :
Enter any 2 numbers : 12 14
Addition is : 26_
Program to calculate subtraction of two
numbers :
/* Program to calculate subtraction of two numbers.
Creation Date : 10:43 PM 21/11/2011
Author : R.K.Singh */
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
clrscr();
printf("n Enter any 2 numbers : ");
scanf("%d %d",&a,&b);
c = a - b;
printf("n Subtraction is : %d",c);
getch();
}
Output :
Enter any 2 numbers : 8 6
Subtraction is : 2_
Program to calculate division of two
numbers :
Program :
/* Program to calculate division of two numbers.
Creation Date : 10:58 PM 21/11/2011
Author : R.K.Singh */
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
clrscr();
printf("n Enter any 2 numbers : ");
scanf("%d %d",&a,&b);
c = a / b;
printf("n Division is : %d",c);
getch();
}
Output :
Enter any 2 numbers : 12 5
Division is : 2_
Program to calculate multiplication of
two numbers :
• Program :
• /* Program to calculate multiplication of two numbers.
• Creation Date : 10:51 PM 21/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int a,b,c;
• clrscr();
• printf("n Enter any 2 numbers : ");
• scanf("%d %d",&a,&b);
• c = a * b;
• printf("n Multiplication is : %d",c);
• getch();
• }
Output :
Enter any 2 numbers : 8 12
Multiplication is : 96_
Program to calculate modulus of two
numbers :
• Program :
• /* Program to calculate modulus of two numbers.
• Creation Date : 11:01 PM 21/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int a,b,c;
• clrscr();
• printf("n Enter any 2 numbers : ");
• scanf("%d %d",&a,&b);
• c = a % b;
• printf("n Modulus is : %d",c);
• getch();
• }
Output :
Enter any 2 numbers : 11 5
Modulus is : 1_
Pyramid in c
Program to print pyramid in C :
Pattern 1 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 1
• Creation Date : 12:36 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j;
• clrscr();
• for(i=0; i<5; i++)
• {
• for(j=0; j<5; j++)
• {
• printf(" * ");
• }
• printf("n");
• }
• getch();
• }
Output :
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *_
Program to print pyramid in C :
Pattern 2 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 2
• Creation Date : 12:43 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j;
• clrscr();
• for(i=0; i<5; i++)
• {
• for(j=0; j<=i; j++)
• {
• printf(" * ");
• }
• printf("n");
• }
• getch();
• }
Output :
*
* *
* * *
* * * *
* * * * *_
Program to print pyramid in C :
Pattern 3 :• /* Program to print pyramid pattern in C : Pattern 3
• Creation Date : 12:28 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j,k;
• clrscr();
• for(i=1; i<=5; i++)
• {
• for(j=5; j>=i; j--)
• {
• printf(" ");
• }
• for(k=1; k<=i; k++)
• {
• printf("*");
• }
• printf("n");
• }
• getch();
• }
Output :
*
* *
* * *
* * * *
* * * * *_
Program to print pyramid in C :
Pattern 4 :• /* Program to print pyramid pattern in C : Pattern 4
• Creation Date : 12:54 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j,k,samp=1;
• clrscr();
• for(i=5; i>=1; i--)
• {
• for(k=samp; k>=0; k--)
• {
• printf(" "); // only 1 space
• }
• for(j=i; j>=1; j--)
• {
• printf("*");
• }
• samp = samp + 1;
• printf("n");
• }
• getch();
• }
Output :
* * * * *
* * * *
* * *
* *
*_
Program to print pyramid in C :
Pattern 5 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 5
• Creation Date : 01:08 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j;
• clrscr();
• for(i=5; i>=1; i--)
• {
• for(j=1; j<=i; j++)
• {
• printf(" * ");
• }
• printf("n");
• }
• getch();
• }
Output :
* * * * *
* * * *
* * *
* *
*_
Program to print pyramid in C :
Pattern 6 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 6
• Creation Date : 01:52 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j,k,t=0;
• clrscr();
• for(i=1; i<=5; i++)
• {
• for(k=t; k<5; k++)
• {
• printf(" ");
• }
• for(j=0; j< i; j++)
• {
• printf(" * ");
• t = t + 1;
• }
• printf("n");
• }
• getch();
• }
Output :
*
* *
* * *
* * * *
* * * * *_
Program to print pyramid in C :
Pattern 7 :• Program :
• /* Program to print pyramid pattern in C : Pattern 7
• Creation Date : 01:13 AM 22/11/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j,k,samp=1;
• clrscr();
• for(i=1; i<=5; i++)
• {
• for(k=samp; k<=5; k++)
• {
• printf(" ");
• }
• for(j=0; j< i; j++)
• {
• printf("*");
• }
• samp = samp + 1;
• printf("n");
• }
• samp = 1;
• for(i=4; i>=1; i--)
• {
• for(k=samp; k>=0; k--)
• {
• printf(" ");
• }
• for(j=i; j>=1; j--)
• {
• printf("*");
• }
• samp = samp + 1;
• printf("n");
• }
• getch();
• }
•
Output :
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*_
Program to print pyramid in C :
Pattern 8 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 8
• Creation Date : 02:39 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int rw, c, no=1 ,len;
• clrscr();
• printf("Enter number of rows: ");
• scanf("%d," &len);
• for(rw=1; rw<=len; rw++)
• {
• printf("n");
• for(c=1; c<=rw; c++)
• {
• printf(" %2d ", no);
• no++;
• }
• }
• getch();
• }
Output :
Enter number of rows: 5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15_
Program to print pyramid in C :
Pattern 9 :• Program :
• /* Program to print pyramid pattern in C : Pattern 9
• Creation Date : 03:19 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int no,i,y,x=35;
• clrscr();
• printf("Enter number of rows: ");
• scanf("%d," &no);
• for(y=0;y<=no;y++)
• {
• goto(x,y+1);
• for(i=0-y; i<=y; i++)
• {
• printf(" %3d ", abs(i));
• x=x-3;
• }
• }
• getch();
• }
Output :
Enter number of rows: 5
0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
5 4 3 2 1 0 1 2 3 4 5_
Program to print pyramid in C :
Pattern 10 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 10
• Creation Date : 03:14 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i, j=5, k, x;
• clrscr();
• for(i=1;i<=5;i++)
• {
• for(k=1;k<=j;k++)
• {
• printf(" ");
• }
• for(x=1;x<=i;x++)
• {
• printf("%d",i);
• printf(" ");
• }
• printf("n");
• j=j-1;
• }
• getch();
• }
Output :
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5_
Program to print pyramid in C :
Pattern 11 :• Program :
• /* Program to print pyramid pattern in C : Pattern 11
• Creation Date : 03:24 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int rw,c,no,spc;
• clrscr();
• printf("Enter number of rows : ");
• scanf("%d", &no);
• for(rw=1; rw<=no; rw++)
• {
• for(spc=no; spc>=rw; spc--)
• {
• printf(" ");
• }
• for(c=1; c<=rw; c++)
• {
• printf("%2d",c);
• }
• printf("n");
• }
• getch();
• }
Output :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5_
Program to print pyramid in C :
Pattern 12 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 12
• Creation Date : 03:24 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j,k;
• clrscr();
• for(i=1; i<=5; i++)
• {
• for(j=1; j<=5-i; j++)
• {
• printf(" ");
• }
• for(k=1; k<=2*i-1; k++)
• {
• printf(" %d ",k);
• }
• printf("n");
• }
• getch();
• }
Output :
1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9_
Program to print pyramid in C :
Pattern 13 :
• Program :
• /* Program to print pyramid pattern in C : Pattern 13
• Creation Date : 04:24 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• int i,j,asci,spc;
• clrscr();
• for(i=7; i>=1; i--)
• {
• for(spc=6; spc>=i; spc--)
• {
• printf(" ");
• }
• asci=65;
• for(j=1; j<=i; j++)
• {
• printf("%2c",asci++);
• }
• for(j=i-1; j>=0; j--)
• {
• printf("%2c",--asci);
• }
• printf("n");
• }
• getch();
• }
Output :
A B C D E F G G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A_
Program to all Combinations of
characters A,B,C in C : Pattern 14 :
• Program :
• /* Program to print all Combinations of characters
A, B, C : Pattern 14
• Creation Date : 11:33 PM 01/10/2011
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
• void main()
• {
• char ch1, ch2, ch3;
• clrscr();
• for(ch1='A' ; ch1<='C' ; ++ch1)
• {
• for(ch2='A' ; ch2<='C' ; ++ch2)
• {
• for(ch3='A' ; ch3<='C' ; ++ch3)
• {
• printf(" %c%c%c", ch1, ch2, ch3);
• }
• }
• }
• getch();
• }
Output :
AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB
BBC BCA BCB BCC CAA CAB CAC CBA CBB CBC CCA CCB CCC_
Addition of two matrices :
Program :
/* Program to demonstrate addition of two matrices. Creation Date : 25 Nov 2011 11:35:00 PM
Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],b[3][3],c[3][3],i,j;
• clrscr();
• printf("nt Enter First Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• printf("nt Enter Second Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&b[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• c[i][j]=a[i][j]+b[i][j];
• }
• }
• printf("nt Matrix Addition is : nn");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• printf("t %d",c[i][j]);
• }
• printf("n");
• }
• getch();
• }
Output :
Enter First Matrix : 2 1 2
3 2 1
2 3 3
Enter Second Matrix : 2 1 0
2 3 0
1 1 2
Matrix Addition is :
4 2 2
5 5 1
3 4 5_
Subtraction of two matrices :
• Program :
•
• /* Program to demonstrate subtraction of two matrices.
• Creation Date : 25 Nov 2011 11:42:08 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],b[3][3],c[3][3],i,j;
• clrscr();
• printf("nt Enter First Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• printf("nt Enter Second Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&b[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• c[i][j]=a[i][j]-b[i][j];
• }
• }
• printf("nt Matrix Subtraction is : nn");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• printf("t %d",c[i][j]);
• }
• printf("n");
• }
• getch();
• }
Output :
Enter First Matrix : 2 1 2
3 2 1
2 3 3
Enter Second Matrix : 2 1 0
2 3 0
1 1 2
Matrix Subtraction is :
0 0 2
1 -1 1
1 2 1_
Multiplication of two matrices :• Program :
• /* Program to demonstrate multiplication of two matrices.
Creation Date : 25 Nov 2011 11:50:11 PM
Author : R.K.Singh */
#include <stdio.h>
• #include <conio.h>
• void main()
• {
• int a[3][3],b[3][3],c[3][3],i,j,k;
• clrscr();
• printf("nt Enter First Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• printf("nt Enter Second Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&b[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• c[i][j]=0;
• for(k=0;k<3;k++)
• {
• c[i][j]=c[i][j]+a[i][k]*b[k][j];
• }
• }
• }
• printf("nt Matrix Multiplication is : nn");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• printf("t %d",c[i][j]);
• }
• printf("n");
• }
• getch();
• }
Output :
Enter First Matrix : 1 2 1
3 2 1
1 2 1
Enter Second Matrix : 3 3 3
1 2 1
1 1 1
Matrix Multiplication is :
6 8 6
12 14 12
6 8 6_
Transpose of matrix :• Program :
•
• /* Program to demonstrate transpose of matrix.
• Creation Date : 26 Nov 2011 12:03:59 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],i,j;
• clrscr();
• printf("nt Enter Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• printf("nt Transpose of Matrix is : nn");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• printf("t%d",a[j][i]);
• }
• printf("n");
• }
• getch();
• }
Output :
Enter Matrix : 2 1 2
3 2 1
2 3 3
Transpose of Matrix is :
2 3 2
1 2 3
2 1 3_
Check matrix is lower triangular or not :
• Program :
•
• /* Program to check lower triangular matrix or not.
• Creation Date : 26 Nov 2011 01:14:54 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],i,j,flg=0;
• clrscr();
• printf("nt Enter 3*3 Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• if(a[i]<a[j] && a[i][j]==0)
• {
• flg=flg+1;
• }
• }
• }
• if(flg==3)
• printf("nn Lower triangular matrix !");
• else
• printf("nn Not lower triangular matrix !");
• getch();
• }
Output :
Enter 3*3 Matrix :
1 0 0
1 1 0
2 2 3
Lower triangular matrix !_
Check matrix is upper triangular or not :
• Program :
•
• /* Program to check upper triangular matrix or not.
• Creation Date : 26 Nov 2011 01:14:54 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],i,j,flg=0;
• clrscr();
• printf("nt Enter 3*3 Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• if(a[i]>a[j] && a[i][j]==0)
• {
• flg=flg+1;
• }
• }
• }
• if(flg==3)
• printf("nn Upper triangular matrix !");
• else
• printf("nn Not Upper triangular matrix !");
• getch();
• }
Output :
Enter 3*3 Matrix :
1 2 3
0 1 1
0 0 3
Upper triangular matrix !_
Check matrix is unit/identity matrix or not :
• Program :
•
• /* Program to check unit/identity matrix or not.
• Creation Date : 26 Nov 2011 08:28:08 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],i,j,flg=0,flg2=0,flg3=0;
• clrscr();
• printf("nt Enter 3*3 Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• if(a[i]<a[j] && a[i][j]==0)
• {
• flg=flg+1;
• }
• if(a[i]>a[j] && a[i][j]==0)
• {
• flg2=flg2+1;
• }
• if(a[i][j]==1)
• {
• flg3=flg3+1;
• }
• }
• }
• if(flg==3 && flg2==3 && flg3==3)
• printf("nn Unit/Identity matrix !");
• else
• printf("nn Not Unit/Identity matrix !");
• getch();
• }
Output :
Enter 3*3 Matrix :
1 0 0
0 1 0
0 0 1
Unit/Identity matrix !_
Check matrix is zero/null matrix or not :
• Program :
•
• /* Program to check zero/null matrix or not.
• Creation Date : 26 Nov 2011 02:09:04 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],i,j,flg=0;
• clrscr();
• printf("nt Enter 3*3 Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• if(a[i][j]==0)
• {
• flg=flg+1;
• }
• }
• }
• if(flg==9)
• printf("nn Zero/Null matrix !");
• else
• printf("nn Not Zero/Null matrix !");
• getch();
• }
Output :
Enter 3*3 Matrix :
0 0 0
0 0 0
0 0 0
Zero/Null matrix !_
Check matrix is diagonal or not :
• Program :
•
• /* Program to check diagonal matrix or not.
• Creation Date : 26 Nov 2011 01:14:54 PM
• Author : R.K.Singh */
• #include <stdio.h>
• #include <conio.h>
•
• void main()
• {
• int a[3][3],i,j,flg=0,flg2=0;
• clrscr();
• printf("nt Enter 3*3 Matrix : ");
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• scanf("%d",&a[i][j]);
• }
• }
• for(i=0;i<3;i++)
• {
• for(j=0;j<3;j++)
• {
• if(a[i]<a[j] && a[i][j]==0)
• {
• flg=flg+1;
• }
• if(a[i]>a[j] && a[i][j]==0)
• {
• flg2=flg2+1;
• }
• }
• }
• if(flg==3 && flg2==3)
• printf("nn Diagonal matrix !");
• else
• printf("nn Not Diagonal matrix !");
• getch();
• }
•
Output :
Enter 3*3 Matrix :
2 0 0
0 5 0
0 0 1
Diagonal matrix !_

More Related Content

PPT
Relasi & Fungsi. power point. matematika. UNIVERSITAS SERAMBI MEKKAH BANDA ACEH
DOC
Bab i-sistem-koordinat
PPTX
Geometri Dimensi Tiga ~ titik, garis dan bidang
PPTX
Definisi dan Kesamaan Polinomial kelas XI.pptx
PDF
1. soal tes i siswa- fix-cover
PPT
Pertemuan 6
PPTX
Sifat sifat operasi fungsi dan komposisi fungsi
PDF
Pertemuan 6 Fungsi String
Relasi & Fungsi. power point. matematika. UNIVERSITAS SERAMBI MEKKAH BANDA ACEH
Bab i-sistem-koordinat
Geometri Dimensi Tiga ~ titik, garis dan bidang
Definisi dan Kesamaan Polinomial kelas XI.pptx
1. soal tes i siswa- fix-cover
Pertemuan 6
Sifat sifat operasi fungsi dan komposisi fungsi
Pertemuan 6 Fungsi String

What's hot (20)

PDF
001 bab i dasar-dasar pc
PPTX
Aljabar boolean
DOCX
Penyajian data 7
PPTX
Akar persamaan
DOCX
rpp sifat-sifat logaritma kurikulum 2013 ( RPP eksponen dan logaritma )
DOC
Soal-soal Latihan TIK Kelas 9
PPTX
Dimensi tiga
DOCX
Integral Fungsi Trigonometri
PDF
9.double linked list circular
DOCX
Contoh Soal Matematika Kombinatorik
PPTX
POLA BILANGAN (BARISAN ARITMATIKA & DERET ARITMATIKA)
PDF
elearning of exercise
PPT
MATERI MICROSOFT EXCEL.ppt
PDF
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
DOCX
11 latihan sisipan, suku tengah, deret aritmatika
PPTX
Presentasi Sistem Digital - Flip Flop
PPTX
Jarak pada bangun ruang
DOCX
DOCX
TUGAS BAHASA C
PDF
Soal Ujian Nasional Matematika smk-2010-p4tkmatematika
001 bab i dasar-dasar pc
Aljabar boolean
Penyajian data 7
Akar persamaan
rpp sifat-sifat logaritma kurikulum 2013 ( RPP eksponen dan logaritma )
Soal-soal Latihan TIK Kelas 9
Dimensi tiga
Integral Fungsi Trigonometri
9.double linked list circular
Contoh Soal Matematika Kombinatorik
POLA BILANGAN (BARISAN ARITMATIKA & DERET ARITMATIKA)
elearning of exercise
MATERI MICROSOFT EXCEL.ppt
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
11 latihan sisipan, suku tengah, deret aritmatika
Presentasi Sistem Digital - Flip Flop
Jarak pada bangun ruang
TUGAS BAHASA C
Soal Ujian Nasional Matematika smk-2010-p4tkmatematika
Ad

Viewers also liked (20)

DOC
C lab-programs
PPT
Basics of C programming
PDF
C program
PDF
important C questions and_answers praveensomesh
DOCX
Lab. Programs in C
DOCX
Practical write a c program to reverse a given number
PDF
C Programming Interview Questions
PDF
نماذج جوجل
PDF
Microsoft word -_microsoft_word_exercise
PDF
Programming with c language practical manual
PPTX
Beginners: Microsoft Office Word 2007 Lesson 2
DOCX
C programs
PDF
Word exercises (1)
PDF
Microsoft word exercises
PDF
Metal Joining Processes: Welding, Riveting, Bolting, Brazing, Soldering
DOC
C programming project by navin thapa
PPT
C ppt
PDF
C programming Lab Manual 15 me47p
PPTX
Intro to Microsoft Word 2010 for Kids
PPTX
Introduction to microsoft word 2007
C lab-programs
Basics of C programming
C program
important C questions and_answers praveensomesh
Lab. Programs in C
Practical write a c program to reverse a given number
C Programming Interview Questions
نماذج جوجل
Microsoft word -_microsoft_word_exercise
Programming with c language practical manual
Beginners: Microsoft Office Word 2007 Lesson 2
C programs
Word exercises (1)
Microsoft word exercises
Metal Joining Processes: Welding, Riveting, Bolting, Brazing, Soldering
C programming project by navin thapa
C ppt
C programming Lab Manual 15 me47p
Intro to Microsoft Word 2010 for Kids
Introduction to microsoft word 2007
Ad

Similar to Simple c program (20)

PDF
Pattern printing-in-c(Jaydip Kikani)
PDF
pattern-printing-in-c.pdf
DOCX
Computer Networks Lab File
PPT
Friend this-new&delete
PPTX
Graphics Programming in C
DOCX
C Programming
DOC
'C' language notes (a.p)
PDF
Pioc
PDF
C Programming Example
PPT
Linux_C_LabBasics.ppt
DOCX
PDF
RDataMining slides-r-programming
PPTX
Presentation1 computer shaan
PPTX
C++Object oriented Programming with C++.pptx
PPTX
C Programming Training in Ambala ! Batra Computer Centre
DOCX
Cd practical file (1) start se
PDF
54602399 c-examples-51-to-108-programe-ee01083101
PDF
Zoro123456789123456789123456789123456789
 
PDF
labb123456789123456789123456789123456789
 
Pattern printing-in-c(Jaydip Kikani)
pattern-printing-in-c.pdf
Computer Networks Lab File
Friend this-new&delete
Graphics Programming in C
C Programming
'C' language notes (a.p)
Pioc
C Programming Example
Linux_C_LabBasics.ppt
RDataMining slides-r-programming
Presentation1 computer shaan
C++Object oriented Programming with C++.pptx
C Programming Training in Ambala ! Batra Computer Centre
Cd practical file (1) start se
54602399 c-examples-51-to-108-programe-ee01083101
Zoro123456789123456789123456789123456789
 
labb123456789123456789123456789123456789
 

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Institutional Correction lecture only . . .
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Cell Structure & Organelles in detailed.
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Cell Types and Its function , kingdom of life
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Pre independence Education in Inndia.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial disease of the cardiovascular and lymphatic systems
Institutional Correction lecture only . . .
GDM (1) (1).pptx small presentation for students
Cell Structure & Organelles in detailed.
Abdominal Access Techniques with Prof. Dr. R K Mishra
Classroom Observation Tools for Teachers
master seminar digital applications in india
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Cell Types and Its function , kingdom of life
Microbial diseases, their pathogenesis and prophylaxis
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Supply Chain Operations Speaking Notes -ICLT Program
Pre independence Education in Inndia.pdf
Complications of Minimal Access Surgery at WLH
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...

Simple c program

  • 1. Simple C Program : Program : /* Simple C Program . Creation Date : 12:34 PM 07/11/2010 Author : R.K.Singh*/ #include <stdio.h> #include <conio.h> void main() { clrscr(); printf("n My first program in C !"); getch(); }
  • 2. Output : My first program in C !_
  • 3. Program to print value of existing number : Program : /* Program to print value of existing number . Creation Date : 12:38 PM 07/11/2010 Author :R.K.Singh */ #include <stdio.h> #include <conio.h> void main() { int no = 19; clrscr(); printf("n Number is : %d",no); getch(); }
  • 5. Program to demonstrate scanf() and printf() : 3.C : Program : /* Program to demonstrate scanf() and printf(). Creation Date : 12:41 PM 07/11/2011 Author : R.K.Singh */ #include <stdio.h> #include <conio.h> void main() { int no; clrscr(); printf("n Enter any number :"); scanf("%d",&no); printf("n Number is : %d",no); getch(); }
  • 6. Output : Enter any number :12 Number is : 12_
  • 8. Program to calculate addition of two numbers : Program : /* Program to calculate addition of two numbers. Creation Date : 09:51 PM 21/11/2011 Author : R.K.Singh */ #include <stdio.h> #include <conio.h> void main() { int a,b,c; clrscr(); printf("n Enter any 2 numbers : "); scanf("%d %d",&a,&b); c = a + b; printf("n Addition is : %d",c); getch(); }
  • 9. Output : Enter any 2 numbers : 12 14 Addition is : 26_
  • 10. Program to calculate subtraction of two numbers : /* Program to calculate subtraction of two numbers. Creation Date : 10:43 PM 21/11/2011 Author : R.K.Singh */ #include <stdio.h> #include <conio.h> void main() { int a,b,c; clrscr(); printf("n Enter any 2 numbers : "); scanf("%d %d",&a,&b); c = a - b; printf("n Subtraction is : %d",c); getch(); }
  • 11. Output : Enter any 2 numbers : 8 6 Subtraction is : 2_
  • 12. Program to calculate division of two numbers : Program : /* Program to calculate division of two numbers. Creation Date : 10:58 PM 21/11/2011 Author : R.K.Singh */ #include <stdio.h> #include <conio.h> void main() { int a,b,c; clrscr(); printf("n Enter any 2 numbers : "); scanf("%d %d",&a,&b); c = a / b; printf("n Division is : %d",c); getch(); }
  • 13. Output : Enter any 2 numbers : 12 5 Division is : 2_
  • 14. Program to calculate multiplication of two numbers : • Program : • /* Program to calculate multiplication of two numbers. • Creation Date : 10:51 PM 21/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int a,b,c; • clrscr(); • printf("n Enter any 2 numbers : "); • scanf("%d %d",&a,&b); • c = a * b; • printf("n Multiplication is : %d",c); • getch(); • }
  • 15. Output : Enter any 2 numbers : 8 12 Multiplication is : 96_
  • 16. Program to calculate modulus of two numbers : • Program : • /* Program to calculate modulus of two numbers. • Creation Date : 11:01 PM 21/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int a,b,c; • clrscr(); • printf("n Enter any 2 numbers : "); • scanf("%d %d",&a,&b); • c = a % b; • printf("n Modulus is : %d",c); • getch(); • }
  • 17. Output : Enter any 2 numbers : 11 5 Modulus is : 1_
  • 19. Program to print pyramid in C : Pattern 1 : • Program : • /* Program to print pyramid pattern in C : Pattern 1 • Creation Date : 12:36 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j; • clrscr(); • for(i=0; i<5; i++) • { • for(j=0; j<5; j++) • { • printf(" * "); • } • printf("n"); • } • getch(); • }
  • 20. Output : * * * * * * * * * * * * * * * * * * * * * * * * *_
  • 21. Program to print pyramid in C : Pattern 2 : • Program : • /* Program to print pyramid pattern in C : Pattern 2 • Creation Date : 12:43 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j; • clrscr(); • for(i=0; i<5; i++) • { • for(j=0; j<=i; j++) • { • printf(" * "); • } • printf("n"); • } • getch(); • }
  • 22. Output : * * * * * * * * * * * * * * *_
  • 23. Program to print pyramid in C : Pattern 3 :• /* Program to print pyramid pattern in C : Pattern 3 • Creation Date : 12:28 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j,k; • clrscr(); • for(i=1; i<=5; i++) • { • for(j=5; j>=i; j--) • { • printf(" "); • } • for(k=1; k<=i; k++) • { • printf("*"); • } • printf("n"); • } • getch(); • }
  • 24. Output : * * * * * * * * * * * * * * *_
  • 25. Program to print pyramid in C : Pattern 4 :• /* Program to print pyramid pattern in C : Pattern 4 • Creation Date : 12:54 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j,k,samp=1; • clrscr(); • for(i=5; i>=1; i--) • { • for(k=samp; k>=0; k--) • { • printf(" "); // only 1 space • } • for(j=i; j>=1; j--) • { • printf("*"); • } • samp = samp + 1; • printf("n"); • } • getch(); • }
  • 26. Output : * * * * * * * * * * * * * * *_
  • 27. Program to print pyramid in C : Pattern 5 : • Program : • /* Program to print pyramid pattern in C : Pattern 5 • Creation Date : 01:08 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j; • clrscr(); • for(i=5; i>=1; i--) • { • for(j=1; j<=i; j++) • { • printf(" * "); • } • printf("n"); • } • getch(); • }
  • 28. Output : * * * * * * * * * * * * * * *_
  • 29. Program to print pyramid in C : Pattern 6 : • Program : • /* Program to print pyramid pattern in C : Pattern 6 • Creation Date : 01:52 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j,k,t=0; • clrscr(); • for(i=1; i<=5; i++) • { • for(k=t; k<5; k++) • { • printf(" "); • } • for(j=0; j< i; j++) • { • printf(" * "); • t = t + 1; • } • printf("n"); • } • getch(); • }
  • 30. Output : * * * * * * * * * * * * * * *_
  • 31. Program to print pyramid in C : Pattern 7 :• Program : • /* Program to print pyramid pattern in C : Pattern 7 • Creation Date : 01:13 AM 22/11/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j,k,samp=1; • clrscr(); • for(i=1; i<=5; i++) • { • for(k=samp; k<=5; k++) • { • printf(" "); • } • for(j=0; j< i; j++) • { • printf("*"); • } • samp = samp + 1; • printf("n"); • } • samp = 1; • for(i=4; i>=1; i--) • { • for(k=samp; k>=0; k--) • { • printf(" "); • } • for(j=i; j>=1; j--) • { • printf("*"); • } • samp = samp + 1; • printf("n"); • } • getch(); • } •
  • 32. Output : * * * * * * * * * * * * * * * * * * * * * * * * *_
  • 33. Program to print pyramid in C : Pattern 8 : • Program : • /* Program to print pyramid pattern in C : Pattern 8 • Creation Date : 02:39 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int rw, c, no=1 ,len; • clrscr(); • printf("Enter number of rows: "); • scanf("%d," &len); • for(rw=1; rw<=len; rw++) • { • printf("n"); • for(c=1; c<=rw; c++) • { • printf(" %2d ", no); • no++; • } • } • getch(); • }
  • 34. Output : Enter number of rows: 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15_
  • 35. Program to print pyramid in C : Pattern 9 :• Program : • /* Program to print pyramid pattern in C : Pattern 9 • Creation Date : 03:19 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int no,i,y,x=35; • clrscr(); • printf("Enter number of rows: "); • scanf("%d," &no); • for(y=0;y<=no;y++) • { • goto(x,y+1); • for(i=0-y; i<=y; i++) • { • printf(" %3d ", abs(i)); • x=x-3; • } • } • getch(); • }
  • 36. Output : Enter number of rows: 5 0 1 0 1 2 1 0 1 2 3 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5_
  • 37. Program to print pyramid in C : Pattern 10 : • Program : • /* Program to print pyramid pattern in C : Pattern 10 • Creation Date : 03:14 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i, j=5, k, x; • clrscr(); • for(i=1;i<=5;i++) • { • for(k=1;k<=j;k++) • { • printf(" "); • } • for(x=1;x<=i;x++) • { • printf("%d",i); • printf(" "); • } • printf("n"); • j=j-1; • } • getch(); • }
  • 38. Output : 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5_
  • 39. Program to print pyramid in C : Pattern 11 :• Program : • /* Program to print pyramid pattern in C : Pattern 11 • Creation Date : 03:24 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int rw,c,no,spc; • clrscr(); • printf("Enter number of rows : "); • scanf("%d", &no); • for(rw=1; rw<=no; rw++) • { • for(spc=no; spc>=rw; spc--) • { • printf(" "); • } • for(c=1; c<=rw; c++) • { • printf("%2d",c); • } • printf("n"); • } • getch(); • }
  • 40. Output : 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5_
  • 41. Program to print pyramid in C : Pattern 12 : • Program : • /* Program to print pyramid pattern in C : Pattern 12 • Creation Date : 03:24 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j,k; • clrscr(); • for(i=1; i<=5; i++) • { • for(j=1; j<=5-i; j++) • { • printf(" "); • } • for(k=1; k<=2*i-1; k++) • { • printf(" %d ",k); • } • printf("n"); • } • getch(); • }
  • 42. Output : 1 1 2 3 1 2 3 4 5 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9_
  • 43. Program to print pyramid in C : Pattern 13 : • Program : • /* Program to print pyramid pattern in C : Pattern 13 • Creation Date : 04:24 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • int i,j,asci,spc; • clrscr(); • for(i=7; i>=1; i--) • { • for(spc=6; spc>=i; spc--) • { • printf(" "); • } • asci=65; • for(j=1; j<=i; j++) • { • printf("%2c",asci++); • } • for(j=i-1; j>=0; j--) • { • printf("%2c",--asci); • } • printf("n"); • } • getch(); • }
  • 44. Output : A B C D E F G G F E D C B A A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A_
  • 45. Program to all Combinations of characters A,B,C in C : Pattern 14 : • Program : • /* Program to print all Combinations of characters A, B, C : Pattern 14 • Creation Date : 11:33 PM 01/10/2011 • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • void main() • { • char ch1, ch2, ch3; • clrscr(); • for(ch1='A' ; ch1<='C' ; ++ch1) • { • for(ch2='A' ; ch2<='C' ; ++ch2) • { • for(ch3='A' ; ch3<='C' ; ++ch3) • { • printf(" %c%c%c", ch1, ch2, ch3); • } • } • } • getch(); • }
  • 46. Output : AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB BBC BCA BCB BCC CAA CAB CAC CBA CBB CBC CCA CCB CCC_
  • 47. Addition of two matrices :
  • 48. Program : /* Program to demonstrate addition of two matrices. Creation Date : 25 Nov 2011 11:35:00 PM Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],b[3][3],c[3][3],i,j; • clrscr(); • printf("nt Enter First Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • printf("nt Enter Second Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&b[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • c[i][j]=a[i][j]+b[i][j]; • } • } • printf("nt Matrix Addition is : nn"); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • printf("t %d",c[i][j]); • } • printf("n"); • } • getch(); • }
  • 49. Output : Enter First Matrix : 2 1 2 3 2 1 2 3 3 Enter Second Matrix : 2 1 0 2 3 0 1 1 2 Matrix Addition is : 4 2 2 5 5 1 3 4 5_
  • 50. Subtraction of two matrices : • Program : • • /* Program to demonstrate subtraction of two matrices. • Creation Date : 25 Nov 2011 11:42:08 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],b[3][3],c[3][3],i,j; • clrscr(); • printf("nt Enter First Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • printf("nt Enter Second Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&b[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • c[i][j]=a[i][j]-b[i][j]; • } • } • printf("nt Matrix Subtraction is : nn"); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • printf("t %d",c[i][j]); • } • printf("n"); • } • getch(); • }
  • 51. Output : Enter First Matrix : 2 1 2 3 2 1 2 3 3 Enter Second Matrix : 2 1 0 2 3 0 1 1 2 Matrix Subtraction is : 0 0 2 1 -1 1 1 2 1_
  • 52. Multiplication of two matrices :• Program : • /* Program to demonstrate multiplication of two matrices. Creation Date : 25 Nov 2011 11:50:11 PM Author : R.K.Singh */ #include <stdio.h> • #include <conio.h> • void main() • { • int a[3][3],b[3][3],c[3][3],i,j,k; • clrscr(); • printf("nt Enter First Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • printf("nt Enter Second Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&b[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • c[i][j]=0; • for(k=0;k<3;k++) • { • c[i][j]=c[i][j]+a[i][k]*b[k][j]; • } • } • } • printf("nt Matrix Multiplication is : nn"); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • printf("t %d",c[i][j]); • } • printf("n"); • } • getch(); • }
  • 53. Output : Enter First Matrix : 1 2 1 3 2 1 1 2 1 Enter Second Matrix : 3 3 3 1 2 1 1 1 1 Matrix Multiplication is : 6 8 6 12 14 12 6 8 6_
  • 54. Transpose of matrix :• Program : • • /* Program to demonstrate transpose of matrix. • Creation Date : 26 Nov 2011 12:03:59 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],i,j; • clrscr(); • printf("nt Enter Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • printf("nt Transpose of Matrix is : nn"); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • printf("t%d",a[j][i]); • } • printf("n"); • } • getch(); • }
  • 55. Output : Enter Matrix : 2 1 2 3 2 1 2 3 3 Transpose of Matrix is : 2 3 2 1 2 3 2 1 3_
  • 56. Check matrix is lower triangular or not : • Program : • • /* Program to check lower triangular matrix or not. • Creation Date : 26 Nov 2011 01:14:54 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],i,j,flg=0; • clrscr(); • printf("nt Enter 3*3 Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • if(a[i]<a[j] && a[i][j]==0) • { • flg=flg+1; • } • } • } • if(flg==3) • printf("nn Lower triangular matrix !"); • else • printf("nn Not lower triangular matrix !"); • getch(); • }
  • 57. Output : Enter 3*3 Matrix : 1 0 0 1 1 0 2 2 3 Lower triangular matrix !_
  • 58. Check matrix is upper triangular or not : • Program : • • /* Program to check upper triangular matrix or not. • Creation Date : 26 Nov 2011 01:14:54 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],i,j,flg=0; • clrscr(); • printf("nt Enter 3*3 Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • if(a[i]>a[j] && a[i][j]==0) • { • flg=flg+1; • } • } • } • if(flg==3) • printf("nn Upper triangular matrix !"); • else • printf("nn Not Upper triangular matrix !"); • getch(); • }
  • 59. Output : Enter 3*3 Matrix : 1 2 3 0 1 1 0 0 3 Upper triangular matrix !_
  • 60. Check matrix is unit/identity matrix or not : • Program : • • /* Program to check unit/identity matrix or not. • Creation Date : 26 Nov 2011 08:28:08 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],i,j,flg=0,flg2=0,flg3=0; • clrscr(); • printf("nt Enter 3*3 Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • if(a[i]<a[j] && a[i][j]==0) • { • flg=flg+1; • } • if(a[i]>a[j] && a[i][j]==0) • { • flg2=flg2+1; • } • if(a[i][j]==1) • { • flg3=flg3+1; • } • } • } • if(flg==3 && flg2==3 && flg3==3) • printf("nn Unit/Identity matrix !"); • else • printf("nn Not Unit/Identity matrix !"); • getch(); • }
  • 61. Output : Enter 3*3 Matrix : 1 0 0 0 1 0 0 0 1 Unit/Identity matrix !_
  • 62. Check matrix is zero/null matrix or not : • Program : • • /* Program to check zero/null matrix or not. • Creation Date : 26 Nov 2011 02:09:04 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],i,j,flg=0; • clrscr(); • printf("nt Enter 3*3 Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • if(a[i][j]==0) • { • flg=flg+1; • } • } • } • if(flg==9) • printf("nn Zero/Null matrix !"); • else • printf("nn Not Zero/Null matrix !"); • getch(); • }
  • 63. Output : Enter 3*3 Matrix : 0 0 0 0 0 0 0 0 0 Zero/Null matrix !_
  • 64. Check matrix is diagonal or not : • Program : • • /* Program to check diagonal matrix or not. • Creation Date : 26 Nov 2011 01:14:54 PM • Author : R.K.Singh */ • #include <stdio.h> • #include <conio.h> • • void main() • { • int a[3][3],i,j,flg=0,flg2=0; • clrscr(); • printf("nt Enter 3*3 Matrix : "); • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • scanf("%d",&a[i][j]); • } • } • for(i=0;i<3;i++) • { • for(j=0;j<3;j++) • { • if(a[i]<a[j] && a[i][j]==0) • { • flg=flg+1; • } • if(a[i]>a[j] && a[i][j]==0) • { • flg2=flg2+1; • } • } • } • if(flg==3 && flg2==3) • printf("nn Diagonal matrix !"); • else • printf("nn Not Diagonal matrix !"); • getch(); • } •
  • 65. Output : Enter 3*3 Matrix : 2 0 0 0 5 0 0 0 1 Diagonal matrix !_