Welcome To Uday Satya Blog

65 - 67 PROGRAMS


/*************************************************          
       65.To find the transpose of a matrix using pointers ************************************************ */
#include<*stdio.h>
#include<*conio.h>
void main()
{
clrscr();
int i,j;
int arr[3][3],tra[3][3];

printf("Enter the elements to the matrix ");

for(i=0;i<3;i++)
 {
for(j=0;j<3;j++)
   scanf("%d",&arr[i][j]);
   }

for(i=0;i<3;i++)
 {
for(j=0;j<3;j++)
  {
*(*(tra+j)+i)=*(*(arr+i)+j);
   }
  }
 printf("The transpose is\n");
for(i=0;i<3;i++)
 {
for(j=0;j<3;j++)
  printf("%d\t",*(*(tra+i)+j));
  printf("\n");
 }
getch();
}

OUTPUT
Enter the elements to the matrix 1 2 3 4 5 6 7 8 9
The transpose is
1       4       7
2       5       8
3       6       9

/* ***********************************
           66.To copy one string to another
   *********************************** */
#include<*stdio.h>
#include<*conio.h>
#include
void main()
{
clrscr();
 char s[100],t[100];
 int l,c,i;
 printf("Enter the string ");
 scanf("%s",&s);

 l=strlen(s);
 for(i=0;i
 {
*(t+i)=*(s+i);
 }
 printf("\nThe entered string is : %s",s);
 printf("\nThe copied string is : %s");
 for(i=0;i
 printf("%c",*(t+i));

getch();
}

OUTPUT
Enter the string Inspire

The entered string is : Inspire
The copied string is : Inspire

/* *****************************************
      67.To calculate the marks using structures
   **************************************** */
#include<*stdio.h>
#include<*conio.h>

void main()
{
clrscr();
 int i;
 struct student
 {
char name[25];
  int roll;
  int m1;
  int m2;
  int total;
  }s[3];

  for(i=0;i<3;i++)
  {
printf("Enter Name ");
   scanf("%s",&s[i].name);
   printf("Enter Roll Number ");
   scanf("%d",&s[i].roll);
   printf("Enter Marks of 1st subject ");
   scanf("%d",&s[i].m1);
   printf("Enter Marks of 2nd subject ");
   scanf("%d",&s[i].m2);
   s[i].total=s[i].m1+s[i].m2;
  }

  for(i=0;i<3;i++)
  {
printf("\nName %s",s[i].name);
   printf("\nRoll No : %d",s[i].roll);
   printf("\nMarks 1 : %d",s[i].m1);
   printf("\nMarks 2 : %d",s[i].m2);
   printf("\nTotal : %d",s[i].total);
   }

  getch();
}

OUTPUT
Enter Name Garima
Enter Roll Number 4
Enter Marks of 1st subject 95
Enter Marks of 2nd subject 90
Enter Name Prerana
Enter Roll Number 16
Enter Marks of 1st subject 80
Enter Marks of 2nd subject 84
Enter Name Nikhil
Enter Roll Number 29
Enter Marks of 1st subject 70
Enter Marks of 2nd subject 93

Name Garima
Roll No : 4
Marks 1 : 95
Marks 2 : 90
Total : 185
Name Prerana
Roll No : 16
Marks 1 : 80
Marks 2 : 84
Total : 164
Name Nikhil
Roll No : 29
Marks 1 : 70
Marks 2 : 93
Total : 163









0 comments:

Post a Comment