#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
struct complex
{
int real;
int img;
};
int main()
{
struct complex a, b, c;
printf(" Enter a and b where a + ib is the first complex number. ");
printf(" \na = ");
scanf(" %d ", &a.real);
printf(" b = ");
scanf(" %d ", &a.img);
printf(" Enter c and d where c + id is the second complex number. ");
printf(" \nc = ");
scanf(" %d ", &b.real);
printf(" d = ");
scanf(" %d ", &b.img);
c.real = a.real + b.real;
c.img = a.img + b.img;
if ( c.img >= 0 )
printf(" Sum of two complex numbers = %d + %di ", c.real, c.img);
else
printf(" Sum of two complex numbers = %d %di ", c.real, c.img);
getch();
return 0;
}
OUTPUT:
Enter a and b where a + ib is the first complex number.
a = 6
b = 2
Enter c and d where c + id is the second complex number.
c = 2
d = 6
Sum of two complex numbers = 8 + 8i
ALSO READ:
-- Program To Print First Ten(10) Natural Numbers.
-- Program To Print Fibonacci Series Upto 100.
-- Program To Check Whether A Number Is Prime Or Not.
-- Program To Compute The Reverse Of A Number.
-- Program To Print A Semicolon Without Using A Semicolon.
-- Program To Display Function Without Using The Main Function.
-- Program To Print Any Print Statement Without Using Semicolon.
-- Program To Display Its Own Source Code As Its Output.
-- Program To Swap Two Strings Using strcpy() Function.
-- Program to accept a string and print the reverse of the given string.
-- Program To Get IP Address.
-- Program To Accept An Integer & Reverse It.
-- Program To Convert Given Number Of Days To A Measure Of Time Given In Years, Weeks & Days.
-- Program To Illustrate The Concept Of Unions.
-- Program To Find The Size Of A Union.
... Back To C++ Programs Index
... Back To C++ FAQ's Index
... Back To C Programs Index
... Back To C FAQ's Index
... Back To HR Interview Index
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com