#include<iostream.h>
#include<conio.h>
struct complex
{
float real;
float image;
};
void display(struct complex c);
int main()
{
struct complex x,y,z;
void add(struct complex a, struct complex b);
void sub(struct complex a, struct complex b);
void mul(struct complex a, struct complex b);
char opr;
clrscr();
cout<<"Enter the first complex no.(first real part and then imaginary part):"<<endl;
cin>>x.real>>x.image;
cout<<"Enter the second complex no.(first real part and then imaginary part):"<<endl;
cin>>y.real>>y.image;
cout<<"Enter the operator(+, -, *) :";cin>>opr;
switch(opr)
{
case '+' :
{
cout<<endl<<"Complex number addition"<<endl;
add(x,y);
break;
}
case '-' :
{
cout<<endl<<"Complex number subtraction"<<endl;
sub(x,y);
break;
}
case '*' :
{
cout<<endl<<"Complex number multiplication"<<endl;
mul(x,y);
break;
}
default : cout<<"Invalid operator" ;
};
getch();
return 0;
}
void add(struct complex a, struct complex b)
{
struct complex z;
z.real = a.real+b.real;
z.image = a.image+b.image;
display(z);
}
void sub(struct complex a, struct complex b)
{ struct complex z;
z.real = a.real - b.real;
z.image = a.image - b.image;
display(z);
}
void mul(struct complex a, struct complex b)
{
struct complex z;
z.real = a.real* b.real - a.image*b.image;
z.image = a.real*b.image + a.image*b.real;
display(z);
}
void display(struct complex c)
{
if(c.image>=0)
cout<<c.real<<"+i"<<c.image;
else
cout<<c.real<<"-i"<<c.image;
}
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement 
Corporate Services
  Web Design and development
  Web Promotion (SEO)
  Multimedia/CD Presentation
  Software development

  E.Commerce

Training@balujalabs

  Software Courses
  Hardware Courses
  Networking.Courses
  Mobile Repairing Courses
  UGC Degrees
Student Corner
 Programming & Projects
 Placement Papers
 Project Ideas
 Synopsis Ideas

  Franchise Section

 Administrator
Franchise Inquiry
 
 

Program to perform arithmetic operations (+,-,*) on given compare numbers using structures.

 

 

 

 

 

 

 

 

 

                                                                                                                                          

1 To initialize the member fields of a structure and display its contents.
2 To assign data to various fields of structure using function and display it.
3 To initiaze member of structures and display them (using arrays).
4 To input records of n students and then display them using nested structure.
5 To initialize data of student and display the contents suing structure operators.
6 To declare structure as a member of a union and display its contents.
7 To enter value of two numbers and display them using anonymous union.
8 To input and display information of a student.
9 To display the contents of a structure passing the individual elements to a function.
10 To pass whole structure to a function.
11 Program to perform arithmetic operations (+,-,*) on given compare numbers using structures.
12 Program to enter and display the data up to 100 books in a library using structure.
13 To enter and display the employee data using nested structure.
14 To input records of students and display the records in ascending order (According to id – no.)
15 Program for using enumerated data type to assign any variable to the enumerated data and then display that number of the using the variables.

 

     
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement