Answers for "switch case in python with functions"

PHP
1

startsWith() and endsWith() functions in PHP

function startsWith($haystack, $needle)
{
     $length = strlen($needle);
     return (substr($haystack, 0, $length) === $needle);
}

function endsWith($haystack, $needle)
{
    $length = strlen($needle);
    if ($length == 0) {
        return true;
    }

    return (substr($haystack, -$length) === $needle);
}
Posted by: Guest on May-18-2020
2

how to make a switch case statement in c++

#include <iostream>
using namespace std;
int main(){
   int num = 5;
   switch(num + 2) {
      case 1: 
        cout << "Case1: Value is: " << num << endl;
      case 2: 
        cout << "Case2: Value is: " << num << endl;
      case 3: 
        cout << "Case3: Value is: " << num << endl;
      default: 
        cout << "Default: Value is: " << num << endl;
   }
   return 0;
}
Posted by: Guest on March-04-2020

Browse Popular Code Answers by Language