Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Sunday, 4 November 2012

transpose of a matrix c program

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}  


#include<stdio.h>
#include<conio.h>
main()
{
      int m[10][10],t[10][10],k,n,d,c;
      printf("enter the metrix");
      scanf("%d%d",&k,&n);
      printf("enter the number");
      for(c=0;c<k;c++)
      {
                      for(d=0;d<n;d++)
                      { 
                                      scanf("%d",&m[c][d]);
                                      }
                                      }
                                      for(c=0;c<k;c++)
      {
                      for(d=0;d<n;d++)
                      { 
                                      t[d][c]=m[c][d];
                                      }
                                      }
                                      printf("transpose of entered matrix:-\n");
                                      for(c=0;c<n;c++)
                                      {
                                                      for(d=0;d<k;d++)
                                                      {
                                                                      printf("%d\t",t[c][d]);
                                                                      }
                                                                      printf("\n");
                                                                      }
                                                                      getch();
                                                                      }


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.


Sunday, 30 September 2012

c program matrix multiplication using arrays

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}  


#include<stdio.h>
#include<conio.h>
main()
{
    int m1[20][20],m2[20][20],mult[20][20],i,j,k,r1,c1,r2,c2;
    printf("Enter number of rows and columns of first matrix (less than 20)\n");
    scanf("%d%d",&r1,&c1);
    printf("Enter number of rows and columns of second matrix (less than 20)\n");
    scanf("%d%d",&r2,&c2);
    if(r2==c1)
    {
        printf("Enter the First matrix \n");
        printf("enter the numbers in Row wise\n");
        for(i=0;i<r1;i++)
            for(j=0;j<c1;j++)
                scanf("%d",&m1[i][j]);
        printf("First Matrix is :\n");
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c1;j++)
                printf("%d\t",m1[i][j]);
            printf("\n");
        }
        printf("Enter the Second matrix \n");
        printf("enter the numbers in Row wise\n");
        for(i=0;i<r2;i++)
            for(j=0;j<c2;j++)
                scanf("%d",&m2[i][j]);
        printf("Second Matrix is:\n");
        for(i=0;i<r2;i++)
        {
            for(j=0;j<c2;j++)
                printf("%d\t",m2[i][j]);
            printf("\n");
        }
        printf("product of the Matrices is:\n");
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c2;j++)
            {
                mult[i][j]=0;
                for(k=0;k<r1;k++)
                    mult[i][j]+=m1[i][k]*m2[k][j];
                printf("%d\t",mult[i][j]);
            }
            printf("\n");
        }
    }
    else
    {
        printf("Matrix multiplication cannot be done");
    }
    getch();
    return 0;
}

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

Friday, 21 September 2012

c program to illustrate a structure(struct)

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.} 


#include<stdio.h>
#include<conio.h>
int main(void)
{
    struct data
    {
           int mounth;
           int day;
           int year;
           };
           struct data today;
           today.mounth = 1;
           today.day = 1;
           today.year = 2000;
           
           printf("The date is %i / %i / %i ",today.mounth,today.day,today.year);
           getch();
           return 0;
           }

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

Sunday, 16 September 2012

c program gcd(greatest common divisor) of two no using function

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}  


#include <stdio.h>
#include<conio.h>
void gcd (int u, int v)
{
int temp;
printf("enter two numbers\n");
scanf("%d%d",&u,&v);
printf ("The gcd of %i and %i is ", u, v);
while ( v != 0 ) {
temp = u % v;
u = v;
v = temp;
}
printf ("%i\n", u);
}
int main (void)
{
    int u,v;
gcd ( u, v);
gcd ( u, v);
gcd ( u, v);
getch();
return 0;
}

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

c program hello world using function

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}


#include<stdio.h>
#include<conio.h>
void print(void)
{
     printf("hellow world");
     }
     int main(void)
     {
         print();
     
         getch();
         return 0;
         }


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

Saturday, 15 September 2012

c program to arrange n numbers in descending order using array

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.} 


#include<stdio.h>
#include<conio.h>
main()
{
      int i,n,j,a[100],t;
      printf("enter the number of elements(only<100) \n ");
      scanf("%d",&n);
      printf("enter the numbers\n");
      for(i=0;i<n;i++)
      {
                      scanf("%d",&a[i]);
                      }
                      printf("number in descending order is\n");
                      for(i=0;i<n;i++)
                      {
                                       for(j=i+1;j<n;j++)
                                       { 
                                                         if(a[i]<=a[j])
                                                         {
                                                                       t=a[i];
                                                                       a[i]=a[j];
                                                                       a[j]=t;
                                                                       }
                                                                       }
                                                                       printf("%d\n",a[i]);
                                                                       }
                                                                       getch();
                                                                       }

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

c program to arrange n numbers in ascending order using array

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.} 


#include<stdio.h>
#include<conio.h>
main()
{
      int i,n,j,a[100],t;
      printf("enter the number of elements(only<100) \n ");
      scanf("%d",&n);
      printf("enter the numbers\n");
      for(i=0;i<n;i++)
      {
                      scanf("%d",&a[i]);
                      }
                      printf("number in ascending order is\n");
                      for(i=0;i<n;i++)
                      {
                                       for(j=i+1;j<n;j++)
                                       { 
                                                         if(a[i]>=a[j])
                                                         {
                                                                       t=a[i];
                                                                       a[i]=a[j];
                                                                       a[j]=t;
                                                                       }
                                                                       }
                                                                       printf("%d\n",a[i]);
                                                                       }
                                                                       getch();
                                                                       }


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

c program for mean using array

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}


#include<stdio.h>
#include<conio.h>
main()
{
      int n,a[100],s=0,i;
      float mean;
      printf("\n enter the number of elements(only<100) \n");
      scanf("%d",&n);
      printf("\n enter the numbers\n");
      for(i=0;i<n;i++)
      {
                      scanf("%d",&a[i]);
                      s=s+a[i];
                      }
                      mean=(float)s/n;
                      printf("\n the mean = %f \n",mean);
                      getch();
                      }


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

Friday, 14 September 2012

c program for matrix addition using array


For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.} 

#include<stdio.h>
#include<conio.h>
main()
{
                 int m1[10][10],m2[10][10],r1,r2,c1,c2,sum[10][10],i,j;
                 printf("enter the order of matrix");
                 printf("\n row \n");
                 scanf("%d",&r1);
                 printf("\n coloumn \n");
                 scanf("%d",&c1);
                 printf("\n enter the order of second matrix \n");
                 printf("\n row \n");
                 scanf("%d",&r2);
                 printf("\n coloumn \n");
                 scanf("%d",&c2);
                 if(r1==r2&&c1==c2)
                 {
                                   printf("\n enter the first matrix \n");
                                   for(i=0;i<r1;i++)
                                   {
                                                     for(j=0;j<c1;j++)
                                                     {
                                                                      scanf("%d",&m1[i][j]);
                                                                      }
                                                                      }
                                                                      printf("entered matrix is");
                                                                      for(i=0;i<r1;i++)
                                   {
                                                                      printf("\n\n");
                                                    for(j=0;j<c1;j++)
                                                    {
                                                                     printf("%5d",m1[i][j]);
                                                                     }
                                                                     }
                                                                      
                                                     printf("\n enter the second matrix \n");
                                                     for(i=0;i<r2;i++)
                                                     {
                                                                      for(j=0;j<c2;j++)
                                                                      {
                                                                                       scanf("%d",&m2[i][j]);
                                                                                       }
                                                                                       }
                                                                                       printf("entered matrix is");
                                                                                       for(i=0;i<r1;i++)
                                   {
                                                                      printf("\n\n");
                                                    for(j=0;j<c1;j++)
                                                    {
                                                                     printf("%5d",m2[i][j]);
                                                                     }
                                                                     }
                                                                                       for(i=0;i<r1;i++)
                                   {
                                                     for(j=0;j<c1;j++)
                                                     {
                                                                      sum[i][j]=m1[i][j]+m2[i][j];
                                                                      }
                                                                      }
                                                                      printf("\n the result is\n");
                                                     for(i=0;i<r1;i++)
                                   {printf("\n\n");
                                                    for(j=0;j<c1;j++)
                                                    {
                                                                     printf("%5d",sum[i][j]);
                                                                     }
                                                                     }
                                                                     }
                                                                     else
                                                                     {
                                                                         printf("\n addition is not possible");
                                                                         }
                                                                         getch();
                                                                         }                  
                                                                     
   For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.