Search This Blog

Thursday, February 10, 2011

addition of two matrix 3x3

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],tot[3][3],i,j;
clrscr();
for(i=0;i<3;i++)
{
 for(j=0;j<3;j++)
 {
 printf("enter element for first matrix");
 scanf("%d",&a[i][j]);
 }
}
for(i=0;i<3;i++)
{
 for(j=0;j<3;j++)
 {
 printf("enter element for second matrix");
 scanf("%d",&b[i][j]);
 }
}
for(i=0;i<3;i++)
{
 for(j=0;j<3;j++)
 {
 printf("%d\t",a[i][j]);
 }
printf("\n");
}
for(i=0;i<3;i++)
{
 for(j=0;j<3;j++)
 {
 printf("%d\t",b[i][j]);
 }
printf("\n");
}
for(i=0;i<3;i++)
{
 for(j=0;j<3;j++)
 {
 tot[i][j]=a[i][j]+b[i][j];
 printf("%d\t",tot[i][j]);
 }
printf("\n");
}
getch();
}

programme to find out max value in array

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],max,b;
clrscr();
for(b=0;b<10;b++)
{
printf("a[%d]=",b);
scanf("%d",&a[b]);
}
max=a[b];
for(b=0;b<10;b++)
{
if(a[b]>max)
max=a[b];
}
printf("the max value is=%d",max);
getch();
}

Programme to check that given number is armstrong or not

#include<stdio.h>
#include<conio.h>
void main()
{
int n,d,s=0,t;
clrscr();
printf("enter value");
scanf("%d",&n);
t=n;
while(n>0)
{
d=n%10;
s=s+d*d*d;
n=n/10;
}
if(t==s)
printf("%d is armstrong number",t);
else
printf("%d isnt armstrong number",t);
getch();
}

Programme to check that given number is palindrome or not

#include<stdio.h>
#include<conio.h>
void main()
{
int n,d,r=0,t;
printf("enter value");
scanf("%d",&n);
t=n;
while(n>0)
{
d=n%10;
r=r*10+d;
n=n/10;
}
if(t==r)
printf("%d is palindrome number",t);
else
printf("%d isnt palingdrome number",t);
getch();
}

Wednesday, February 9, 2011

to interchange two values

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter value for A and B=");
scanf("%d%d",&a,&b);
/*real logic starts from here*/
c=b;
b=a;
a=c;
printf("now a is=%d\nand b is=%d",a,b);
getch();
}

output:
enter value for A and B=10 12
now a is=12
and b is=10

addition of two values

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;/*int is data type AND a and b is two variables */
printf("enter value for a and b=");
scnaf("%d%d",&a,&b");
printf("total of %d and %d  is=%d",a,b,a+b);
getch();
}

first programme in c

#include<stdio.h>/*header file*/
#include<conio.h>/*header file*/
void main()
{
printf("hello world!");/* printf will print hello world! as output*/
getch();
}