mardi 19 mai 2020

can anyone explain the use of ternary oparator in cout statement, i have tried some other way but not working

input 8,11 output eight nine even odd can anyone explaint the cout statement?

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    string c[]={"one","two","three","four","five","six","seven","eight","nine"};
    cin>>a>>b;
    for(int i=a;i<=b;i++)
        cout<<((i<=9)?c[i]:((i%2==0)?"even":"odd"))<<endl; //explain this
}

Aucun commentaire:

Enregistrer un commentaire