1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MAXImum [283]
2 years ago
13

Write a program that uses the function isPalindrome given below. Test your program on the following strings: madam, abba, 22, 67

876, 444244, trymeuemyrt. Modify the function isPalindrome given so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. bool isPalindrome(string str)
{
int length = str.length();

for (int i = 0; i < length / 2; i++)
{
if (str[i] != str[length - 1 - i] )
return false;
}

return true;
}
Engineering
1 answer:
defon2 years ago
5 0

Answer:

#include <iostream>

#include <string>

using namespace std;

bool isPalindrome(string str)

{

   int length = str.length();

   for (int i = 0; i < length / 2; i++)

   {

       if (tolower(str[i]) != tolower(str[length - 1 - i]))

           return false;

   }

   return true;

}

int main()

{

   string s[6] = {"madam", "abba", "22", "67876", "444244", "trymeuemyrt"};

   int i;

   for(i=0; i<6; i++)

   {

       //Testing function

       if(isPalindrome(s[i]))

       {

           cout << "\n " << s[i] << " is a palindrome... \n";

       }

       else

       {

           cout << "\n " << s[i] << " is not a palindrome... \n";

       }

   }    

       

   return 0;

}

You might be interested in
Given : f(x) = x³- 7x²+ 36 Draw the graph of f neatly on F graph paper. Clearly indicate an Intercepts and coordinates of turnin
vichka [17]

Answer:

Explanation:

xx=33 vvalues

7 0
2 years ago
A large tank is filled to capacity with 500 gallons of pure water. Brine containing 2 pounds of salt per gallon is pumped into t
Nataly [62]

Answer:

A) A(t) = 10(100 - t) + c(100 - t)²

B) Tank will be empty after 100 minutes.

Explanation:

A) The differential equation of this problem is;

dA/dt = R_in - R_out

Where;

R_in is the rate at which salt enters

R_out is the rate at which salt exits

R_in = (concentration of salt in inflow) × (input rate of brine)

We are given;

Concentration of salt in inflow = 2 lb/gal

Input rate of brine = 5 gal/min

Thus;

R_in = 2 × 5 = 10 lb/min

Due to the fact that the solution is pumped out at a faster rate, thus it is reducing at the rate of (5 - 10)gal/min = -5 gal/min

So, after t minutes, there will be (500 - 5t) gallons in the tank

Therefore;

R_out = (concentration of salt in outflow) × (output rate of brine)

R_out = [A(t)/(500 - 5t)]lb/gal × 10 gal/min

R_out = 10A(t)/(500 - 5t) lb/min

So, we substitute the values of R_in and R_out into the Differential equation to get;

dA/dt = 10 - 10A(t)/(500 - 5t)

This simplifies to;

dA/dt = 10 - 2A(t)/(100 - t)

Rearranging, we have;

dA/dt + 2A(t)/(100 - t) = 10

This is a linear differential equation in standard form.

Thus, the integrating factor is;

e^(∫2/(100 - t)) = e^(In(100 - t)^(-2)) = 1/(100 - t)²

Now, let's multiply the differential equation by the integrating factor 1/(100 - t)².

We have;

So, we ;

(1/(100 - t)²)(dA/dt) + 2A(t)/(100 - t)³ = 10/(100 - t)²

Integrating this, we now have;

A(t)/(100 - t)² = ∫10/(100 - t)²

This gives;

A(t)/(100 - t)² = (10/(100 - t)) + c

Multiplying through by (100 - t)²,we have;

A(t) = 10(100 - t) + c(100 - t)²

B) At initial condition, A(0) = 0.

So,0 = 10(100 - 0) + c(100 - 0)²

1000 + 10000c = 0

10000c = -1000

c = -1000/10000

c = -0.1

Thus;

A(t) = 10(100 - t) + -0.1(100 - t)²

A(t) = 1000 - 10t - 0.1(10000 - 200t + t²)

A(t) = 1000 - 10t - 1000 + 20t - 0.1t²

A(t) = 10t - 0.1t²

Tank will be empty when A(t) = 0

So, 0 = 10t - 0.1t²

0.1t² = 10t

Divide both sides by 0.1t to give;

t = 10/0.1

t = 100 minutes

6 0
3 years ago
Initialize the tuple team_names with the strings 'Rockets', 'Raptors', 'Warriors', and 'Celtics' (The top-4 2018 NBA teams at th
Drupady [299]

Answer:

#Initialise a tuple

team_names = ('Rockets','Raptors','Warriors','Celtics')

print(team_names[0])

print(team_names[1])

print(team_names[2])

print(team_names[3])

Explanation:

The Python code illustrates or printed out the tuple team names at the end of a season.

The code displayed is a function that will display these teams as an output from the program.

4 0
3 years ago
Explain 3 ways that people in sports use engineering to increase their performance?
LenKa [72]
Designing systems for manufacturing, motion analysis or impact testing;
building and testing prototypes;
analyzing the human body to prevent injury;
developing or designing new light weight materials that will be more comfortable and withstand greater impacts or forces;
7 0
2 years ago
When a variable is stored in memory, it is associated with an address. To obtain the address of a variable, the &amp; operator c
liubo4ka [24]

Answer:

Explanation:

1) C program file addressOfScalar.c

#include <stdio.h>

int main()

{

//intialize a char variable, print its address and the next address

char charvar = 'a';

printf("address of charvar = %p\n", (void *)(&charvar));

printf("address of charvar - 1 = %p\n", (void *)(&charvar - 1));

printf("address of charvar + 1 = %p\n", (void *)(&charvar + 1));

//intialize a int variable, print its address and the next address

int intvar = 1;

printf("address of intvar = %p\n", (void *)(&intvar));

printf("address of intvar - 1 = %p\n", (void *)(&intvar - 1));

printf("address of intvar + 1 = %p\n", (void *)(&intvar + 1));

}

In C programming language, an int variable takes 4 bytes of memory. So any arithmetic on integer address, always considers it as 4 bytes of data. So intvar-1 refers to a location 4 bytes before intvar's address and intvar+1 refers to 4 bytes after intvar's address.

3 0
3 years ago
Other questions:
  • A 400-m^3 storage tank is being constructed to hold LNG, liquefied natural gas, which may be assumed to be essentially pure meth
    8·1 answer
  • The structure supports a distributed load of w. The limiting stress in rod (1) is 370 MPa, and the limiting stress in each pin i
    5·1 answer
  • JAVA HADOOP MAPREDUCE
    13·1 answer
  • Shear plane angle and shear strain: In an orthogonal cutting operation, the tool has a rake angle = 16°. The chip thickness befo
    7·1 answer
  • The costs of mining and transporting coal are roughly independent of the heating value of the coal. Consider:
    15·1 answer
  • which one of the following appliance parts gets the hardest services? A. Heating elementwhich one of the following appliance par
    10·2 answers
  • What have you learned from the previous lesson? Let's try to check your prior knowledge
    9·1 answer
  • Advanced manufacturing does NOT serve the transportation, communications, or medical industries. Is this statement TRUE or FALSE
    11·2 answers
  • Two solid yellow center lines on a two-lane highway indicate:
    13·2 answers
  • How to clean a snowblower carburetor without removing it.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!