Write
a program to illustate the comparison of structure variables
#include<stdio.h>
#include<conio.h>
struct class
{
int number;
char name[20];
float marks;
};
main()
{
int x;
//Declaring and initializing structures of 'class' type
struct class student2 = {2, "gita", 78.00};
struct class student3;
student3 = student2;
// Copying student2 to student3
This will copy values of members of student2 to corresponding
members of student3
if ((student3.number = student2.number) && (student3.marks =
student2.marks)) // verifying results of copy
{
printf("\n student2 and student3 are equal");
printf("%d %s %f\n", student3.number, student3.name,
student3.marks);
}
else
printf ("\n student2 and student3 are different");
}
Output:
student2 and student 3 are equal.