Computer Science, asked by chiraga7605, 1 year ago

rewrite the following code using if else if statement.
switch(direction)
{
case "N" : a = "North"; break;
case "E" : a = "East"; break;
case "W" : a = "West"; break;
case "S" : a = "South"; break;
default : a = "Enter correct code";
}
document.write (a)

Answers

Answered by tinashemphisa
5

int main(){

   char direction;

   cout<<"enter the direction"<<endl;

   cin>>direction;

   if(direction=='n' || direction=='N'){

       cout<<"North"<<endl;

   } else

   if(direction=='e' || direction=='E'){

       cout<<"East"<<endl;

   }else

   if(direction=='w' || direction=='W'){

       cout<<"West"<<endl;

   }else

   if(direction=='s' || direction=='S'){

       cout<<"South"<<endl;

   }else{

       cout<<"Enter correct code"<<endl;

   }

return 0;

}


Answered by shirisha1981
0

Answer:int main(){

  char direction;

  cout<<"enter the direction"<<endl;

  cin>>direction;

  if(direction=='n' || direction=='N'){

      cout<<"North"<<endl;

  } else

  if(direction=='e' || direction=='E'){

      cout<<"East"<<endl;

  }else

  if(direction=='w' || direction=='W'){

      cout<<"West"<<endl;

  }else

  if(direction=='s' || direction=='S'){

      cout<<"South"<<endl;

  }else{

      cout<<"Enter correct code"<<endl;

  }

return 0;

}

Read more on Brainly.in - https://brainly.in/question/7336308#readmore

Similar questions