Contact Learn C
Copy

Program 364: Add N Complex Numbers using Structures

Program 364: Add N Complex Numbers using Structures
 
#include<stdio.h>
 struct Complex{
  int realPart,imaginaryPart;
 };
main()
{
 int n,i;
 printf("Enter number of Complex number to be added\n");
 scanf("%d",&n);
 Complex c[n],total;
 total.realPart=0;
 total.imaginaryPart=0;
 for(i=0;i<n;i++)
 {
  printf("Enter real part of %d number\n",i+1);
  scanf("%d",&c[i].realPart);
  printf("Enter imaginary part of %d number\n",i+1);
  scanf("%d",&c[i].imaginaryPart);
  total.realPart+=c[i].realPart;
  total.imaginaryPart+=c[i].imaginaryPart;
 }
 
 if(total.imaginaryPart>=0)
     printf("%d+%di\n",total.realPart,total.imaginaryPart);
 else
     printf("%d%di\n",total.realPart,total.imaginaryPart);
 
 
}
Explanation:
 //Coming Soon


Output:



Add N Complex Numbers using Structures
Add N Complex Numbers using Structures

1 comment:

  1. college-party-guide One of the most important rituals for students in college is to throw the most memorable student dorm celebration.
    factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.
    factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.
    gigolo The term”gigolo” usually refers to the person who lives an arranged lifestyle that includes many of these relationships in a series, rather than having any other support system.
    y2mate.com y2mate.com is a well-known password management system. It lets you download all your favourite videos and audios.
    IGTools.net The term”gigolo” usually refers to the person who lives an arranged lifestyle that includes many of these relationships in a series, rather than having any other support system.
    sniffies Sniffies isn’t bookmarked on my phone, however I’ve been logged in enough that the web target will auto-complete on my personal browser.

    ReplyDelete

Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide