Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Complex Numbers

Complex Numbers

Scheduled Pinned Locked Moved Managed C++/CLI
questionhelp
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 41487
    wrote on last edited by
    #1

    I am having a few problems with the following code: int main(){ double a, b, c, d; cout << "Enter the first complex number:"; cin >> a >> b; cout << "Enter the second complex number: "; cin >> c >> d; cout << "(" << a << "+" << b <<"i)" << " + (" << c << d << "i) = "; cout << Sum(a,b,c,d)<< endl; return 0; } double Sum(double& a, double& b, double& c, double& d){ double i; double sum1, sum2; sum1 = (a + c); sum2 = i*(b + d); return (sum1 + sum2); } When go to print the function to the screen will not display (7-i) but instead prints the value 7. How do I get around this problem? :confused:

    S 1 Reply Last reply
    0
    • U User 41487

      I am having a few problems with the following code: int main(){ double a, b, c, d; cout << "Enter the first complex number:"; cin >> a >> b; cout << "Enter the second complex number: "; cin >> c >> d; cout << "(" << a << "+" << b <<"i)" << " + (" << c << d << "i) = "; cout << Sum(a,b,c,d)<< endl; return 0; } double Sum(double& a, double& b, double& c, double& d){ double i; double sum1, sum2; sum1 = (a + c); sum2 = i*(b + d); return (sum1 + sum2); } When go to print the function to the screen will not display (7-i) but instead prints the value 7. How do I get around this problem? :confused:

      S Offline
      S Offline
      Slayer
      wrote on last edited by
      #2

      Because u didn't identify i the output has some errs.Do not identify i by using double,identify it like characters.And finnaly add it to answer. cout<<(a+c)+(b+d)<<".i"; like this .ok?? However if u want to make some other calculations on complex number theory , you have to identify the special properties of i.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups