IT Branch

Transpose and diagonal sum of a Matrix- C Program

#include<stdio.h>
int main()
{
  int a[10][10],b[10][10],i,c,j,k=0,m,n,sum=0;
  printf("\nenter your choice");
  printf("\n1.Transpose\n2.Diagonal sum\n");
  scanf("%d",&c);
  printf("\nEnter the row and column of matrix: \n");
  scanf("%d %d",&m,&n);
 
  printf("\nEnter the elements of matrix->");
  for(i=0;i<m;i++)
  {
      for(j=0;j<n;j++)
      {
           scanf("%d",&a[i][j]);
      }
  }
  printf("\nThe matrix is\n");

Sub string Display- C Program

#include<stdio.h>

int main()

{
    char s[100];
    int i=0,j,k=0,l=0,ctr;
    printf("\nEnter a string:");    
      scanf("%[^\n]",s);
    printf("\nthe substrings in the string are :\n");
    while(s[l]!='\0')
    {
     for(i=0;s[i]!=' '||s[i]!='\0';i++)
     {
       printf("%c",s[i]);
            if (s[i]==' ')
            {
               printf("\n");
            }

            if (s[i]=='\0')
               break;
               l++;
     }
   }

Reverse of a number- C Program

#include<stdio.h>

int main()
{
    int n,n1,r=0,s=0;
    printf("\n enter the number ");
    scanf("%d",&n);
    n1=n;
    while(n1!=0)
    {
                r=n1%10;
                n1/=10;
                s=s*10+r;
    }
    printf("\n %d is the reverse of the no %d",s,n);
   
}

Pages