Question
39

C++ language
include comments pls
if you can type it that would be great
( alot easier to read)

The number 6 is a truly great number. Given two int values, A and B, write a function to return True if either one is 6. Or i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

hi,

here is the code that satisfies the above conditions in Cpp language:

code.cpp

#include <iostream>
using namespace std;
// Function prototype (declaration)
bool love6(int, int);
int main()
{
//declaring two variables to read numbers from user
int num1, num2;
//propting user to enter the two numbers
cout<<"Enters two numbers to check: ";
//getting the input from the user using cin
cin >> num1 >> num2;
// Function call to check the numbers
std::cout << std::boolalpha << love6(num1, num2) << std::endl;
return 0;
}
// Function definition
//bool type is used for return the true/false
bool love6(int a, int b)
{
//if either of A and B are belongs to 6, it will return true
if(a==6 || b==6){
return true;
}else if(a+b==6){//if sum of A and B is equals to 6 it will return true
return true;
}else if(a-b==6 || b-a==6){ //if difference between A and B are 6 then it will return true
return true;
}else{// if all the above cases failed, then it will return false.
return false;
}
}

Add a comment
Know the answer?
Add Answer to:
39 C++ language include comments pls if you can type it that would be great (...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The number 6 is a truly great number. Given two int values, a and b, return...

    The number 6 is a truly great number. Given two int values, a and b, return true if either one is 6. Or if their sum or difference is 6. Note: the function Math.abs(num) computes the absolute value of a number. loveSix(6, 4)  true loveSix(4, 5)  false loveSix(1, 5)  true For example: Test Result System.out.println(loveSix(14, 4)); false

  • Question 3 Program Language C++ Problem 3 Fibonacci Numbers 10 points Fibonacci numbers are a sequence...

    Question 3 Program Language C++ Problem 3 Fibonacci Numbers 10 points Fibonacci numbers are a sequence of numbers where each number is represented by the sum of the two preceding numbers, starting with 0 and 1: 0, 1, 1, 2, 3, 5, 8, etc Write a program that repeatedly prompts the user for a positive integer and prints out whether or not that integer is a Fibonacci number. The program terminates when-I is entered. Create a method with the following...

  • //Look for** to complete this program --C+ please --please add comments // using namespace std; #include...

    //Look for** to complete this program --C+ please --please add comments // using namespace std; #include <iostream> #include <stdlib.h> #include < string> #include "queue.h" //Purpose of the program: ** Algorithm: * int main() /** "A", "B", "C" in the queue //** while loop -- indefinitely { try {//** catches } //* end of loop } |/ II II II II II //File type: ** queue.cpp using namespace std; #include <iostream> #include "queue.h" // constructor queue::queue () } //destructor queue::~queue() queue::queue...

  • Using the C Programming Language: An integer number is said to be a perfect number if...

    Using the C Programming Language: An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a function perfect that determines if parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each...

  • Write Java code to implement a FSM machine that recognizes the language for the alphabet {a,b,c} ...

    Write Java code to implement a FSM machine that recognizes the language for the alphabet {a,b,c} consisting of all strings that contain two consecutive c's and end with b.                   Your FSM program should include the following three static methods (Java) or functions (C):                                           a.    int nextState(int state, char symbol)                                  A state-transition function that returns the next state based on the                                  current state and an input symbol. This function should also return                                  -1 when an invalid input character is detected.                                  State...

  • can someone please help me solve these problem in c++ language and leave useful comments below...

    can someone please help me solve these problem in c++ language and leave useful comments below so i can follow along and know what i am doing /view wa New Tab CSSO IDE 15 THE DIGIT SWAP PROBLEM Write a function named swapDigitPairs() that accepts a positive integer n as an input-output parameter which is changed to a new value similar to n's but with each pair of digits swapped in order. For example: int n = 482596; int old...

  • I need help solving this in c++ using visual Studio. For this assignment, you will be filling in missing pieces of code within a program, follow the comments in the code. These comments will describe...

    I need help solving this in c++ using visual Studio. For this assignment, you will be filling in missing pieces of code within a program, follow the comments in the code. These comments will describe the missing portion. As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. // TicTacToe.cpp: Follow along with...

  • NEED HELP IN C!! Answer in C programming language. Question: Functions and .h file: Test function:...

    NEED HELP IN C!! Answer in C programming language. Question: Functions and .h file: Test function: part 1: part 2: For the assignment use the following structs for Binary Trees and Binary Search Trees. struct Binode { int value; struct Binode* left; struct BTnode* right; struct BTnode* parent; }; typedef struct Binode BTnode_t; typedef struct BST { BTnode_t* root; BST_t; Question 2 [10 points] Write a function that gets a binary tree and returns the sum of its elements. //...

  • C programming language Purpose The purpose of this assignment is to help you to practice working...

    C programming language Purpose The purpose of this assignment is to help you to practice working with functions, arrays, and design simple algorithms Learning Outcomes ● Develop skills with multidimensional arrays ● Learn how to traverse multidimensional arrays ● Passing arrays to functions ● Develop algorithm design skills (e.g. recursion) Problem Overview Problem Overview Tic-Tac-Toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the...

  • C++ myStack.lh stackADT.h Instructions main.cpp 1 #include«iostream» 2 #include<stdlib.h> 3 #include«conio.h> 4 #include«ostream» 5 using namespace std; 6 const int SIZE-5; //Stack size 7 //...

    C++ myStack.lh stackADT.h Instructions main.cpp 1 #include«iostream» 2 #include<stdlib.h> 3 #include«conio.h> 4 #include«ostream» 5 using namespace std; 6 const int SIZE-5; //Stack size 7 //class declaration 8 class stack Instructions Two stacks of the same type are the same if they have the same number of elements and their elements at the corresponding positions are the same Overload the relational operatorfor the class stackType that returns true if two stacks of the same type are the same; it returns false...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT