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
forsale [732]
3 years ago
12

Please save the program with the name ‘palindrome.c’Write a functionand its prototypewhichreturn true if the string parameter is

a palindrome.Apalindrome is any "word" which is the same forward and backward, eg, "radar", "noon", "20011002", ... The function should return false if the argument is not a palindrome. Please try to use functions that we have learned in class.This is the output example:
Engineering
1 answer:
seraphim [82]3 years ago
3 0

Answer:

The solution code is written in C.

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdbool.h>
  4. bool isPalindrome(char str[])
  5. {
  6.    int length = strlen(str) ;
  7.    bool status = true;
  8.    int i;
  9.    
  10.    for(i = 0; i < length / 2; i++){
  11.      
  12.        if(str[i] != str[length - 1 - i]){
  13.            status = false;
  14.            return status;
  15.        }
  16.    }
  17.    
  18.    return status;
  19. }

Explanation:

Firstly, we need to include libraries<em> stdio, string </em>and<em> stdbool </em> (Line 1 -3)<em>.</em>

Next, we create a function<em> isPalindrome</em> that take one string parameter and return a boolean value (Line 5).

We use function strlen to get the length to the input string (Line 7). At this point, let's set our <em>status</em> as true (Line 8).

We create a for-loop to traverse through the characters inside the input string (Line 11). Within the loop, we set a condition that compare the first letter to the letter started from the last index (Line 13). If the letters are not matched, this means the input string is not a palindrome and set the status as false and return it as output (Line 14 - 15).

Otherwise, the for-loop will just terminate without running the statements within the if-block and return status as true (Line 19).

You might be interested in
How to make a police car ​
S_A_V [24]

search it and you will get on internet

3 0
3 years ago
Give me source code of Simple openGL project. ( without 3D or Animation) simple just.
Ivan

Answer:

Use GitHub or stackoverflow for this answer

Explanation:

It helps with programming a lot

4 0
3 years ago
On what frequency can you expect to monitor air traffic in and around<br> Lincoln Airport?
Phantasy [73]

Answer:

118.5

Explanation:

Hope this helps!

5 0
3 years ago
C#: Arrays - Ask the user how many students names they want to store. You will create two parallel arrays (e.g. 2 arrays with th
zhenek [66]

Answer:

  1. using System;      
  2. public class Program
  3. {
  4. public static void Main()
  5. {
  6.  Console.WriteLine("Enter number of students: ");
  7.  int num = Convert.ToInt32(Console.ReadLine());
  8.  string [] firstName = new string[num];
  9.  string [] lastName = new string[num];
  10.  
  11.  for(int i=0 ; i < num; i++){
  12.   Console.WriteLine("Enter first name: ");
  13.   firstName[i] = Console.ReadLine();
  14.    
  15.   Console.WriteLine("Enter last name: ");
  16.   lastName[i] = Console.ReadLine();
  17.  }
  18.  
  19.  for(int j=0; j < num; j++){
  20.   Console.WriteLine(lastName[j] + "," + firstName[j]);
  21.  }
  22. }
  23. }

Explanation:

Firstly, prompt user to enter number of student to be stored (Line 6- 7). Next, create two array, firstName and lastName with num size (Line 8-9).

Create a for-loop to repeat for num times and prompt user to enter first name and last name and then store them in the firstName and lastName array, respectively (Line 11 - 17).

Create another for loop to traverse through the lastName and firstName array and display the last name and first name by following the format given in the question (Line 19 - 21).

4 0
3 years ago
Suppose you have two boxes in front of you. One box contains a Thevenin Equivalent (voltage source in series with a resistor) an
fomenos

Answer:

1. Measure the temperature of the boxes and leave them unconnected.

2. Norton reduces his circuit down to a single resistance in parallel with a constant current source. A real-life Norton equivalent circuit would be continuously wasting power (as heat) as the current source dumps energy into the resistor, even when externally unconnected, while a Thevenin equivalent circuit would sit there doing nothing.

3. The Norton equivalent box would get warm and eventually run out of power. The Thevenin equivalent box would stay at ambient temperature.

8 0
4 years ago
Other questions:
  • You are comparing distillation column designs at 1 atm and 3 atm total pressure for a particular separation. You have the same f
    5·1 answer
  • Explain the differences between planned and predictive maintenance.
    12·1 answer
  • A venturi meter is to be installed in a 63 mm bore section of a piping system to measure the flow rate of water in it. From spac
    15·1 answer
  • 1. A farmer had 752 sheep and took one shot that got them all. How did he do it?
    9·1 answer
  • While having a discussion, Technician A says that you should never install undersized tires on a vehicle. The vehicle will be lo
    11·1 answer
  • Write the following statements as Prolog clauses, in the order given: If it is raining or snowing, then there is precipitation.
    15·1 answer
  • The pressure intensity at a point in a fluid is equal in all directions a.true b.false​
    12·1 answer
  • What is applied technology?
    14·1 answer
  • How would you expect an increase in the austenite grain size to affect the hardenability of a steel alloy? Why?
    13·1 answer
  • Contrast moral and immoral creativity and innovation<br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!