Question

Multi Part question for c++ and yes I'll rate you up thank youu! ^^ Part A:...

Multi Part question for c++ and yes I'll rate you up thank youu! ^^

Part A: Define a struct for a Circle with a radius, circumference, area.

Then define an array with 10 Circles.

Input the radius for each circle from the user (and also set its circumference, area).

Then output the area of the largest circle in the array.

Part B :

Write a function that takes as input a string from the user.

Then it checks if the string is a palindrome.

A palindrome is a string that is the same forwards and backwards.

The code outputs "yes it is a palindrome" or "not a palindrome".

Part C :

Write a program that takes as input 2 strings from the user. Then it determines if one string is a permutation of the other string.

Part D :

If the program answers "yes" to the previous question, meaning the two strings are permutations of each other, determine if each string has all unique characters

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part B)

CODE

int main(){

char string1[20];

int i, length;

int flag = 0;

cout << "Enter a string: ";

getline(cin, string1);

length = strlen(string1);

for(i=0;i < length ;i++){

if(string1[i] != string1[length-i-1]){

flag = 1;

break;

}

}

if (flag) {

cout << string1 << " is not a palindrome" << endl;

}

else {

cout << string1 << " is a palindrome" << endl;

}

system("pause");

return 0;

}

Part C)

CODE

/* function to check whether two strings are

Permutation of each other */

bool arePermutation()

{

string str1, str2;

cout << "Enter str1: ";

getline(cin, str1);

cout << "Enter str2: ";

getline(cin, str2);

  // Get lenghts of both strings

  int n1 = str1.length();

  int n2 = str2.length();

  // If length of both strings is not same,

  // then they cannot be Permutation

  if (n1 != n2)

  return false;

  // Sort both strings

  sort(str1.begin(), str1.end());

  sort(str2.begin(), str2.end());

  // Compare sorted strings

  for (int i = 0; i < n1; i++)

  if (str1[i] != str2[i])

    return false;

  return true;

}

NOTE: As per Chegg policy, I am allowed to answer only 2 coding questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Multi Part question for c++ and yes I'll rate you up thank youu! ^^ Part A:...
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
  • Multi part question c++ and yes I'm going to rate you up thank youu! Part A...

    Multi part question c++ and yes I'm going to rate you up thank youu! Part A Ask the user to input a string. Then sort the string in reverse lexicographic order and print it out. This would be done using the integer values of the characters (ASCII table). Use any one of the sorting methods. For example: if the user enters "zeta" sorting it in reverse lexicographic order would give "ztea". if the user enters "ZETA" it would give "ZTEA"....

  • Multi Part question for c++ thank you and yes I'm going to rate you up thanks...

    Multi Part question for c++ thank you and yes I'm going to rate you up thanks ^^ Part A Question #1 Write a program that takes as input 2 strings from the user. Then it determines if one string is a permutation of the other string. Question #2 If the program answers "yes" to the previous question, meaning the two strings are permutations of each other, determine if each string has all unique characters. Hint: For comparing strings you can...

  • Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h,...

    Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h, P1.cpp The user enters 3 floating-pointer numbers which correspond to 3 radi. Store these numbers in an array. Then, define and prototype a function void area and cireffloat* area, float circumference, float array) which takes as input the array of circumferences of circles with the input radii. Think about why we need to pass pointers for both the area and the circumference variables. radii...

  • For this assignment, you will create a program that tests a string to see if it...

    For this assignment, you will create a program that tests a string to see if it is a palindrome. A palindrome is a string such as “madam”, “radar”, “dad”, and “I”, that reads the same forwards and backwards. The empty string is regarded as a palindrome. Write a recursive function: bool isPalindrome(string str, int lower, int upper) that returns true if and only if the part of the string str in positions lower through upper (inclusive at both ends) is...

  • Hello, The C++ question is: ------------------------------------------------------------------------------- Write a program that takes as input 2 strings from...

    Hello, The C++ question is: ------------------------------------------------------------------------------- Write a program that takes as input 2 strings from the user. Then it determines if one string is a permutation of the other string. If the program answers "yes" to the previous question, meaning the two strings are permutations of each other, determine if each string has all unique characters. --------------------------------------------------------------------------------- I have completed the first part but I am unsure on how to also determine if each string is all unique characters...

  • Write a program that calculates the area and circumference of a circle. It should ask the...

    Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • C++ Class and Operator Overloading part 1 The source file contains a C++ program that declares...

    C++ Class and Operator Overloading part 1 The source file contains a C++ program that declares and initializes an array of Circles. The program is using a for loop statement to find the largest circle in the array and display it on the output screen. However, the program is currently not working. The problem is the program uses logical operator ' > ' for comparison of circles and it is not working unless we overload such operator for the class...

  • Question 11 (20 points) Given the class Point below, define a class Circle that represent a...

    Question 11 (20 points) Given the class Point below, define a class Circle that represent a circle with a given center and radius. The circle class should have a center attribute named center as well as a floating point radius attribute. The center is a point object, defined by the class Point. The class should also have these members: the constructor of the class, which should take parameters to initialize all attributes - a getter for center a setter for...

  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

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