0% found this document useful (0 votes)
33 views2 pages

INLAB

This C code takes in the real and imaginary parts of two complex numbers as input, and outputs the sum and product of the complex numbers. It defines functions to add and multiply complex numbers, and takes input, calls the functions, and prints outputs. The main function scans in the real and imaginary parts, calls the add and multi functions, and prints the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

INLAB

This C code takes in the real and imaginary parts of two complex numbers as input, and outputs the sum and product of the complex numbers. It defines functions to add and multiply complex numbers, and takes input, calls the functions, and prints outputs. The main function scans in the real and imaginary parts, calls the add and multi functions, and prints the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

INPUT FORMAT

The first line contains the number, nThe second line contains the position, pOutput Format:Print
either Odd or Even

CODE:

#include< stdio.h >

void main()

int p,i=0,a[10];

long int n;

scanf("%d%d",&n,&p);

while(n > 0)

a[i++]=n%10;

n/=10;

if(a[i-p]%2==0)

printf("Even");

else

printf("Odd");

Computer scientist

INPUT FORMAT

Real part of complex number1

Imaginary part of complex number1

Real part of complex number2

Imaginary part of complex number2


OUTPUT FORMAT:

Resultant complex number represented as

real part +/- imaginary part followed by an i

CODE:

#include< stdio.h >

void add(int r1,int i1,int r2,int i2)

if(i1+i2 > 0)

printf("%d+%di\n",r1+r2,i1+i2);

else

printf("%d%di\n",r1+r2,i1+i2);

void multi(int r1,int i1,int r2,int i2)

int d=(r1*i2)+(r2*i1);

if(d > 0)

printf("%d+%di",(r1*r2)-(i1*i2),d);

else

printf("%d%di",(r1*r2)-(i1*i2),d);

void main()

int r1,r2,i1,i2;

scanf("%d%d%d%d",&r1,&i1,&r2,&i2);

add(r1,i1,r2,i2);

add(r1,i1,-r2,-i2);

multi(r1,i1,r2,i2);

You might also like