

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Assigned: 11/13, Tue Due: 11/17, Sat
A complex number is a number of the form a+ib where a and b are real numbers (e.g. 1.5 + 3.0i). Sum and difference of complex numbers are defined component wise i.e. (a1+ib1) + (a2+ib2) = (a1+a2) + i(b1+b2) and (a1+ib1) - (a2+ib2) = (a1-a2) + i(b1-b2). See http://en.wikipedia.org/wiki/Complex_number for details. Save this program in a file called p1.c.
Example 1: Enter first complex number: 20.22+i Enter first complex number: 2+i Sum:22.219999 + i11. Difference:18.219999 + i7.
Example 2: Enter first complex number: 2+i Enter first complex number: 23+i Sum:25.000000 + i7. Difference:-21.000000 + i-1.
Example 3: Enter first complex number: 0+i Enter first complex number: 0+i Sum:0.000000 + i0. Difference:0.000000 + i0.
Save this program in a file called p2.c. You don’t have to handle the cases with invalid input. You must read input from the terminal till the user enters a -1. -1 is not a part of the list.
Example 1: Enter integers, ending with -1. 9 8 7 6 5 4 3 2 1 - 9 8 7 6 5 4 3 2 1
Example 2: Enter integers, ending with -1. 1 2 3 4 5 6 7 8 9 - 1 2 3 4 5 6 7 8 9
Example 1: Enter integers, ending with -1. 5 4 3 2 1 - Array before sorting: 5 4 3 2 1 Array after sorting: 1 2 3 4 5
Example 2: Enter integers, ending with -1. 1 1 1 1 1 - Array before sorting: 1 1 1 1 1 Array after sorting: 1 1 1 1 1
Example 3: Enter integers, ending with -1. 12 - Array before sorting: 12 Array after sorting: 12
Instructions for submitting Assignment 11