Problem:- C Program To Add Two Complex Numbers By Passing Structure With Function Using Structure In C or C++ Program to Add Complex Numbers by Passing Structure or Adding two complex numbers using Structure in C or C Program To Add Two Complex Numbers By Passing Structure With Function or C program to Add two Complex Numbers using structures or C program to add two complex numbers or Write a C Program to add two complex numbers by passing structure or C Program to Add two Complex Numbers or Complex Number Using Struct or C++ program to add, subtract, multiply and divide two complex or Program to add two complex numbers.
What Is Structure
The structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. The structure is used to represent a record. Suppose you want to store a record of Student which consists of student name, address, roll number and age. You can define a structure to hold this information.
Defining a structure
struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.
Syntax :
struct structure_name
{
//Statements
};
Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.
Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.
Solution:-
#include <stdio.h>
typedef struct complex
You May Also See
1. C Program To Calculate Factorial Of A Given Number
2. C Program To Read Integer (N) And Print First Three Powers (N^1, N^2, N^3)
3. C Program For Denomination of an Amount Using While Loop
4. C Program For Reverse A given Number Using While Loop
5. C Program To Find Number Is Armstrong Or Not using While Loop
6. C Program to Calculate Sum of Natural Numbers Using While Loop
7. C Program To Print Multiplication Table Using For Loop
8. C Program to Display Fibonacci Series Using While Loop
9. C Program to Find GCD of two Numbers Using For Loop
10. C Program to Find LCM of two Numbers Using while Loop
What Is Structure
The structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. The structure is used to represent a record. Suppose you want to store a record of Student which consists of student name, address, roll number and age. You can define a structure to hold this information.
Defining a structure
struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.
Syntax :
struct structure_name
{
//Statements
};
Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.
Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.
Solution:-
#include <stdio.h>
typedef struct complex
{
float real;
float imag;
}complex;
complex add(complex n1,complex n2);
int main()
{
complex n1,n2,temp;
printf("For 1st complex number \n");
printf("Enter real and imaginary respectively:\n");
scanf("%f%f",&n1.real,&n1.imag);
printf("\nFor 2nd complex number \n");
printf("Enter real and imaginary respectively:\n");
scanf("%f%f",&n2.real,&n2.imag);
temp=add(n1,n2);
printf("Sum=%.1f+%.1fi",temp.real,temp.imag);
return 0;
}
complex add(complex n1,complex n2)
{
complex temp;
temp.real=n1.real+n2.real;
temp.imag=n1.imag+n2.imag;
return(temp);
}
Output:-
float real;
float imag;
}complex;
complex add(complex n1,complex n2);
int main()
{
complex n1,n2,temp;
printf("For 1st complex number \n");
printf("Enter real and imaginary respectively:\n");
scanf("%f%f",&n1.real,&n1.imag);
printf("\nFor 2nd complex number \n");
printf("Enter real and imaginary respectively:\n");
scanf("%f%f",&n2.real,&n2.imag);
temp=add(n1,n2);
printf("Sum=%.1f+%.1fi",temp.real,temp.imag);
return 0;
}
complex add(complex n1,complex n2)
{
complex temp;
temp.real=n1.real+n2.real;
temp.imag=n1.imag+n2.imag;
return(temp);
}
Output:-
You May Also See
1. C Program To Calculate Factorial Of A Given Number
2. C Program To Read Integer (N) And Print First Three Powers (N^1, N^2, N^3)
3. C Program For Denomination of an Amount Using While Loop
4. C Program For Reverse A given Number Using While Loop
5. C Program To Find Number Is Armstrong Or Not using While Loop
6. C Program to Calculate Sum of Natural Numbers Using While Loop
7. C Program To Print Multiplication Table Using For Loop
8. C Program to Display Fibonacci Series Using While Loop
9. C Program to Find GCD of two Numbers Using For Loop
10. C Program to Find LCM of two Numbers Using while Loop
0 Comments: