Q:

palindrome string using dart programming

0

write dart program to do the following:

Ask the user for a string and print out whether this string is a palindrome or not. A palindrome is a string that reads the same forwards and backwards.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import 'dart:io';

void main() {
  
  stdout.write("Please give a word: ");
  String input = stdin.readLineSync()!.toLowerCase();
  String revInput = input.split('').reversed.join('');
  
  if(input == revInput){
       print("The word is palindrome");
      }
  else {
       print("The word is not a palindrome");
  }
      
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now