C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Create a class named Complex which contains:

  • data field named real of type double
  • data field named imag of type double
  • no-arg constructor that initializes real & imag to 0
  • parametrized constructor with specified values for real & imag
  • overloaded stream extraction operator << that will display a complex number in the form a + bi
  • overloaded stream insertion operator >> that will ask the user for real and imag part of the complex number
  • overloaded binary + operator and a binary – operator
  • overloaded binary * operator and / operator
  • function mag() that will return the magnitude of the complex number.
  • function conjuage() that returns the conjugate of a complex number

Sample:

Enter the first complex number

Enter real part:  3

Enter imag part: 4

Enter the second complex number

Enter real part:  4

Enter imag part: -6

You entered the numbers

C1 = 3 + 4i

C2 = 4 – 6i

1: Addition

2: Subtraction

3: Multiplication

4: Division

5: Magnitude

6: conjugate

9: Quit

Enter your selection: 1

C1 + C2  = 7 - 2i



2.



1. Create a class node with following attributes



a. Data



b. Next pointer



c. constructor and destructor



d. accessor and mutator



2. Now create a class LLQueue with following attributes



a. Front pointer



b. Rear pointer



c. Enqueue: Adds an item to the queue.



d. Dequeue: Removes an item from the queue.



e. Peek



f. Length



g. Clever_display



h. Clever_search



i. Create a priority queue, that rearranges the colors in a rainbow fashion.



i. Red Orange Yellow Green Indigo Blue Voilet

Implement a calculator using bitwise operators and for loops only. Your program should run correctly for positive integers only. You calculator should be able to perform following operations. Basic arithmetic functions (Addition, subtraction, division and multiplication); Square – to compute the square of the given value and Power – to compute the power of an integer. It should take two int arguments number and its power. Any operation that uses operators other than bitwise operators will be awarded zero marks


Write a c++ program which produce the given sequence (in alternative arrangement and reverse order using for loop statement)





Example input: 5




Output: 5, 1, 4, 2, 3, 3, 2, 4, 1, 5

#include<stdio.h>

#include<conio.h>

void main(){

int num1, num2;

int temp=0;

printf("Enter two numbers");

scanf("%d %d" ,&num1,&num2);

 

while(((num1 + num2) % 5) !=0)

  {

   temp=num1+num2;

   num1=num2;

   num2= temp;

   printf("%d",temp);

}

getch();

}


Compound interest is the addition of interest to the principal (original) sum of a loan or deposit, or in



other words, interest on interest. It is the result of reinvesting interest, rather than paying it out, so that



interest in the next period is then earned on the principal sum plus previously-accumulated interest.



The compound interest is calculated using the formula below.




A = P(1 + (r/100))^n




Where:



A = total amount after n year



P = Principal or Original price



r = rate of interest per annum



N = number of years the money is invested







1 Write a program that will calculate the compound interest using the formula above with an annual interest



rate of 5.4 %.

Hope Michael, a DBIT student did 8 units in an exam and got different marks in each of the exam papers. She intends to calculate her total, mean score and exams verdict for the exams using a program written in C++. Requirements/Guide. (All the instructions below should be done in the same single program)

i. Assign 8 scores to Hope in a one-dimensional array. [2 Marks]

ii. Declare a function that takes an array of Hope’s scores as a parameter and calculates both the total and the mean score. [3 Marks]

iii. Pass the mean score from (ii) above into another function by reference, that computes whether Hope has passed or not given that a pass is 50 – 100 while a fail is 0 – 49.99 Marks. [3 Marks]

iv. Display Hope’s results as follows: (this is a sample output, use arbitrary values in your solution) [2 Marks]

Student Name: Hope Michael

Test Scores: 40, 50, 60, 80, 98, 82, 70, 32

Total Marks: 512

Mean Score: 64

Exams Verdict: Pass 

Draw a empty stairs patten using nested loop in c++

Create a program that accepts numbers of pennies to make change for 387


dollars= 3

quarters=3

dimes=1

nickels=0

pennies=2


A perfect number is an integer that is equal to the sum of its factors. For example, 6 is a perfect number as 6 = 3+2+1. Write down a program that takes an integer x as an input and prints all perfect numbers from 1 to x.

LATEST TUTORIALS
APPROVED BY CLIENTS