OneCompiler

if-else ,Easy!!

  • Generate the code that allows "yes" to be printed if a = 10 else print "no":
  • !!we using while loop!!
 #include <iostream>
 using namespace std;
 
 int main(){
   int a;
   
   while(a!=10){
     a = a++;
   }
   
   if(a==10){
     cout<<"yes";
   }
   else{
     cout<<"no";
   }
 }
  • Result:

yes

  • if a != 10:

no
____________________________________

  • Orders are executed if the condition is met and other orders are not executed!

    • Creat your code!!