# Record manual 45-55 programs for ECE-A and ECE-B

45)Transpose of a matrix and test for symmetry
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,row1,row2,col1,col2,a[10][10],b[10][10];
clrscr();
printf("\nEnter order of matrix a");
scanf("%d%d",&row1,&col1);
printf("\nEnter the elements of matrix A:\n");
for(i=0;i<row1;i++)
for(j=0;j<col1;j++)
scanf("%d",&a[i][j]);
for(i=0;i<row1;i++)
{
for(j=0;j<col1;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
row2=col1;
col2=row1;
for(i=0;i<row1;i++)
for(j=0;j<col1;j++)
b[j][i]=a[i][j];
printf("\n The matrix transpose is\n");
for(i=0;i<row2;i++)
{
for(j=0;j<col2;j++)
printf("%4d",b[i][j]);
printf("\n");
}
getch();
}

47)Demonstrate dynamic memory management functions
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void main()
{
int i,sum=0,*p,x,y,*q,s=0;
clrscr();
printf("\n Enter number of elements in array p:");
scanf("%d",&x);
p=(int*)malloc(x*2);
q=(int*)calloc(y,2);
printf("\n Enter Elements of array p:");
for(i=0;i<x;i++)
{
printf("\n %d Element:",i+1);
scanf("%d",&p[i]);
}
for(i=0;i<x;i++)
{
sum=sum+p[i];
}
printf("\n Enter number of elements in array q:");
scanf("%d",&y);
printf("\n Enter elements of array q:");
for(i=0;i<y;i++)
{
printf("\n%d Element:",i+1);
scanf("%d",&q[i]);
}
for(i=0;i<y;i++)
{
s=s+q[i];
}
printf("\nSum of all elements in array p=%d",sum);
printf("\n Sum of all elements in array q:%d",s);
getch();

}

48) Define a structure type ABS, that contains
name,age,destination and salary.Using this structure, write a
programe to read this information for one person from the
keyboard and print the same on screen.
#include<stdio.h>
#include<conio.h>
struct ABS
{
char name[100];
int age;
char designation[100];
float salary;
};
int main()
{
struct ABS person;
clrscr();
printf("\n Enter the name:");
gets(person.name);
printf("\n Enter the designation:");
gets(person.designation);
printf("\n Enter the age:");
scanf("%d",&person.age);
printf("\n Enter salary:");
scanf("%f",&person.salary);
printf("\n***********************************************************");
printf("\n Person Details:");
printf("\n***********************************************************");
printf("\nName:%s\tAge:%d\nDesignation:%s\tSalary:%f",person.name,person.age,person.
designation,person.salary);
getch();
return 0;
}

50) Write a program to illustrate the comparison of
structures, arrays within structure and structure with in
structure
‘OR’
To calculate the subject wise and student wise total and store
as part of the structure
#include<stdio.h>
#include<conio.h>
struct student
{
int roll;
char name[40];
struct birthday
{
int day;
char month[40];
int year;
}DOB;
int sub[3];
int total;
float avg;
};
int main()
{
int i,n,j;
struct student s[50];
clrscr();
printf("\n Enter how many students are there in the class:");
scanf("%d",&n);
printf("\n Enter %d student's details");
for(i=0;i<n;i++)
{
printf("\n Enter number of %d Student:",i);
scanf("%d",&s[i].roll);
printf("\n Enter the name:");
scanf("%s",s[i].name);
printf("\n Entre DOB:");
scanf("%d%s%d",&s[i].DOB.day,s[i].DOB.month,&s[i].DOB.year);
s[i].total=0;

printf("\n Enter the marks of student:");
for(j=0;j<3;j++)
{
scanf("%d",&s[i].sub[j]);
s[i].total=s[i].total+s[i].sub[j];
}
s[i].avg=s[i].total/3;
}
clrscr();
printf("\n******************************************************************");
printf("\n Student details:");
printf("\n******************************************************************");
for(i=0;i<n;i++)
{
printf("\n%dth Student:",i+1);
printf("\nRoll number:%d\t Name:%s\nDOB:%d-%s%d\ntotal=%d\taverage=%f",s[i].roll,s[i].name,s[i].DOB.day,s[i].DOB.month,s[i].DOB.year,s
[i].total,s[i].avg);
}
getch();
return 0;
}

51) Write C program that uses function to perform the
following operations:
(2) Writing a complex number
(3) Addition of two complex numbers
(4) Multiplication of two complex numbers
#include<stdio.h>
#include<conio.h>
struct complex
{
float r,i;
};
int main()
{
float real,img;
struct complex c1,c2;
clrscr();
printf("\n Enter c1 :");
scanf("%f%f",&c1.r,&c1.i);
printf("\n Enter c2:");
scanf("%f%f",&c2.r,&c2.i);
real=c1.r+c2.r;
img=c1.i+c2.i;
printf("\nc1+c2 = %f+(%f)i",real,img);
printf("\nSubtraction:");
real=c1.r-c2.r;
img=c1.i-c2.i;
printf("\nc1-c2 = %f+(%f)i",real,img);
printf("\n Multiplication");
real=c1.r*c2.r-c1.i*c2.i;
img=c1.r*c2.r+c2.i*c1.i;
printf("\nc1*c2 = %f+(%f)i",real,img);
getch();
return 0;
}