Questions: 11 448

Answers by our Experts: 10 707

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 & Filtering

Instructions:

  1. Declare and define hasConsonant() function with he following details: int return type name hasConsonant parameter char
  2. Return value - 1if there is atleast 1 consonant and 0 if there is none. Include Both capital and small letters when checking


Code:

#include <iostream>

using namespace std;


// TODO: Declare the hasConsonant() function here

int hasConsonant(int code)

  

int main(void) {

  char code[100];


  cout << "Enter the code: ";

  cin >> code;


  int result = hasConsonant(code);


  if(result == 1) {

    cout << "ALERT! There is a consonant in the code!";

  } else if(result == 0) {

    cout << "There is no consonant in the code. Situation is under control!";

  }


  return 0;

}


// TODO: Define the hasConsonant() function here


#include <iostream>

using namespace std;


int main(void) {

  int winnings[100] = {

    1,3,2,4,5,7,6,8,9,11,

    100,13,0,14,16,17,3,18,20,10,

    12,8,15,14,5,17,19,18,1,9,5,

    10,13,11,14,16,22,0,18,20,3,

    99,13,15,14,22,17,19,0,23,2,

    12,13,15,22,16,17,56,18,44,99,

    2,13,22,14,16,89,19,69,101,34,

    12,22,15,14,78,17,69,18,2,33,

    4,13,77,7,10,17,19,91,4,22,

    12,98,15,14,15,17,19,18,7

  };


  // TODO: Compute and print the sum of all the winnings here


  return 0;

}



In this task, we implement multiple inheritance. We create two classes, a ‘Mammal’ and a


‘Bird’ class. Then we create another class which inherits both the classes, we name the third


class ‘Organism’. Consider including the following attributes and functionalities to your


classes.


class Mammal


 void setMammalName(string);


 void showMammal();


class Bird


 void setBirdName(string);


 void showBird();


class Organism


 void setOrganismName(string);


 void showOrganism();


 char* getOrganismName();

How to display a c++program showing five students plus there registration numbers.





Write a program that reads in two integers and determines and prints if the first is a




multiple of the second.




a) first the program using if statements




b) then the program using if/else statements

(iv) Write a function, computePrice that receives two parameters: the first one is a character variable

indicating the size of the pizza (S, M or L) and the second an integer variable indicating the number of

toppings on the pizza. It then computes the cost of the pizza and returns the cost as a floating point

number according to the rules:

• Small pizza = R50 + R5.50 per topping

• Medium pizza = R70 + R6.50 per topping

• Large pizza = R90 + R7.50 per topping


(iii) Write a function void rectangle(int w, int h) to print an open rectangle of asterisks (*). The parameters w and h are the width and the height of the rectangle, expressed in number of asterisks.


(ii) Write a void function that receives four int parameters: the first two by value and the last two by reference. Name the formal parameters n1, n2, sum and diff. The function should calculate the sum of the two parameters passed by value and then store the result in the first variable passed by reference. It should calculate the difference between the two parameters passed by value and then store the result in the second parameter passed by reference. When calculating the difference, subtract the larger value from the smaller value. Name the function calcSumAndDiff.


(i) Write a function that returns the cube of the integer passed to it. For example cube(2) will

return 8 and

cube(3) will return 27.



Find the error(s) in each of the following program segments and explain how the error(s) can be

corrected:

(i) int function1()

{

cout << "Inside function function1 " <<

endl; int function2()

{

cout << "Inside function function1 " << endl;

}

}

(ii) int sum(int x, int y)

{

int result;

result = x +

y;

}

(iii) int computeProd(int n)

{

if (n == 0)

return 0;

else

}

n * computeProd(n – 1);

(iv) void aFunction(float a)

{

float a;

cout << a << endl;

}

(v) void theProduct()

{

int

a;

int

b;

int

c;

int result;

cout << “Enter three integers “ <<

endl; cin >> a >> b >> c;

result = a * b * c;

cout << “Result is “ << result <<

endl; return result;

(vi) float calculateSquare(float number)

{

return number * number;

}


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS