GATE Exam  >  GATE Questions  >  Consider the following codeint DO(char *gate)... Start Learning for Free
Consider the following code
int DO(char *gate)
{
char *gate1 = gate;
char *gate2 = gate + strlen (gate) – 1;
while (gate1 < =gate2)
{
if (*gate1 ++! = *gate2 --)
Return 0;
}
return 1;
}
Q. What is the functionality of above function Do ()?
  • a)
    Check whether string is odd palindrome.
  • b)
    Check whether the string is even palindrome
  • c)
    Check whether the string is palindrome
  • d)
    None of above
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
Consider the following codeint DO(char *gate){char *gate1 = gate;char ...
Here two pointers are used gate 1 and gate 2. One pointer points to beginning and other to the end. Loop is a set up that compares the characters pointed by these two pointers. If the characters do not match then it’s not a palindrome. It returns 1 for both even and odd palindrome.
View all questions of this test
Most Upvoted Answer
Consider the following codeint DO(char *gate){char *gate1 = gate;char ...
There seems to be a syntax error in the provided code. The function definition is incomplete, and there is a missing semicolon after `strlen(gate)`.

To fix this, you can complete the function definition and add a semicolon at the end of the line. Here's the corrected code:

```c
int DO(char *gate) {
char *gate1 = gate;
char *gate2 = gate;
int length = strlen(gate);
// Rest of the code...
}
```

This code declares two pointers (`gate1` and `gate2`) and assigns them the value of `gate`. It also calculates the length of the string `gate` using `strlen` function and stores it in the `length` variable.
Explore Courses for GATE exam
Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer?
Question Description
Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer?.
Solutions for Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer?, a detailed solution for Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? has been provided alongside types of Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the following codeint DO(char *gate){char *gate1 = gate;char *gate2 = gate + strlen (gate) – 1;while (gate1 < =gate2){if (*gate1 ++! = *gate2 --)Return 0;}return 1;}Q. What is the functionality of above function Do ()?a)Check whether string is odd palindrome.b)Check whether the string is even palindromec)Check whether the string is palindromed)None of aboveCorrect answer is option 'C'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev