#10: Ternary Operator in C | C Programming for Beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025

ความคิดเห็น • 270

  • @programizstudios
    @programizstudios  2 ปีที่แล้ว +5

    🚀 Loved the tutorial? Take it further with Programiz PRO!
    Refine your skills, conquer coding fears, and build confidence with interactive lessons, quizzes, and challenges. Strengthen your programming foundation and master C today! 👉Start Here: bit.ly/c-master

  • @AlaskarAbdoul
    @AlaskarAbdoul ปีที่แล้ว +43

    /*
    Can you create a program to check whether a number is odd or eve?
    > Use a ternary operator to check if the number is odd or even.
    > If number is odd, print "The number is Odd"
    > If number is even, print "The number is Even"
    */
    #include
    int main() {
    int number;
    printf("Enter a number: ");
    scanf("%d", &number);
    // by using Ternary Operator
    (number % 2==0) ? printf("The number is Even") : printf("The number is Odd");
    }

  • @hurulaynmuhamedsalimcedarp5770
    @hurulaynmuhamedsalimcedarp5770 3 ปีที่แล้ว +40

    Programming Task:
    #include
    int main() {
    int number;
    printf("Enter a number: ");
    scanf("%d", &number);
    (number%2 == 0) ? printf("%d is an even number.", number) : printf("%d is an odd number.", number);
    return 0;
    }

    • @msreekanth8886
      @msreekanth8886 8 หลายเดือนก่อน +1

      wtf

    • @joechen9498
      @joechen9498 6 หลายเดือนก่อน +2

      #include
      int main() {
      int number;
      printf("Please enter the number:");
      scanf("%d", &number);
      (number%2 == 0) ?
      printf("Number is an even number"):
      printf("Number is an odd number");
      return 0;
      }

  • @michaelspencer6008
    @michaelspencer6008 2 ปีที่แล้ว +17

    You did an excellent job explaining the switch statement. I was and am still amazed at how easy you made this so understandable. Please continue teaching us. You have an absolute gift in how you explain these concepts. Thank you sooo much!

    • @ShacklesBindMe
      @ShacklesBindMe 9 หลายเดือนก่อน

      hey buddy! How much part of C have you completed to date?

  • @rhythmahmed1873
    @rhythmahmed1873 2 ปีที่แล้ว +43

    //Can you create a program to check whether a number is odd or even?
    //***Use a ternary operator to check if the number is odd or even
    //***If the number is odd print the number is odd
    //***If the number is even print the number is even
    #include
    int main() {
    int number;
    printf("Enter a number: ");
    scanf("%d", &number);
    (number % 2==0) ? printf("The number is Even.") : printf("The number is Odd.");
    return 0;
    }

    • @nuetrkn
      @nuetrkn 2 ปีที่แล้ว

      Thank you

    • @yasminehey3854
      @yasminehey3854 2 ปีที่แล้ว

      i did the same thing and it worked but later on i made the ternary as
      int result=(number % 2==0) ? printf("The number is Even.") : printf("The number is Odd.");
      but when i print the resut
      itdoes say in the output whether the number is odd or even but it always adds 13 or 14
      i dont understand why there is the "14 or 13 "

    • @sanargasimov
      @sanargasimov ปีที่แล้ว

      @@yasminehey3854 The program then checks whether 'num' is even or odd using the modulus operator %, and uses the ternary operator to print a message indicating whether the number is even or odd.
      However, the use of 'printf' in the ternary operator is not recommended because it returns the number of characters printed, not the value of the condition. As a result, the value of result will be 23 or 19, depending on the message printed.
      A better approach would be to use a separate variable to store the message, and then print that variable and the value of result separately. Here's an updated version of the program:
      #include
      int main()
      {
      int num = 78;
      char* message = (num % 2 == 0) ? "Your number is EVEN" : "Your number is ODD";
      printf("%s
      ", message);
      int result = (num % 2 == 0) ? 0 : 1;
      printf("%d
      ", result);
      return 0;
      }
      This program first declares a char* variable named message, and assigns it a string value based on whether num is even or odd. It then uses printf to print message and a newline character.
      Finally, it declares an int variable named result, and assigns it a value of 0 if num is even or 1 if num is odd. It then uses printf to print result and a newline character.

    • @sammuchina8189
      @sammuchina8189 ปีที่แล้ว +1

      in this part of your code,
      " (number % 2==0) ? printf("The number is Even.") : printf("The number is Odd."); "
      what does the % mean kindly🙏

    • @muhammadfukii1518
      @muhammadfukii1518 ปีที่แล้ว

      @@sammuchina8189 % is could be DEVISION or as per our concept REMAINDER

  • @batmanelhakeky
    @batmanelhakeky ปีที่แล้ว +5

    Your tutorials are so helpful. i learnt switch statement and im now learning tenrary operator. keep the great work up!

  • @shankaradari4741
    @shankaradari4741 2 ปีที่แล้ว +6

    Really useful content I really want to thank the teachers who are making the classes

  • @rahulc.h2440
    @rahulc.h2440 ปีที่แล้ว +16

    for the quiz, it opts C coz in the if-else statement the if part is evaluated to be true and hence gives 5 so the same principle applies Ternary:- (CONDITION) ? Statement1(Executed when True) : Statement2(Executed when False)

  • @Judyy.Sabryy
    @Judyy.Sabryy ปีที่แล้ว +2

    Love it, explantion was clear and straightforward, however, I suggest you also talk about how to implement nested Ternary operators.

    • @annettewairimu5542
      @annettewairimu5542 9 หลายเดือนก่อน

      how are you doing after 5 months in programming?

  • @rakesh1045
    @rakesh1045 ปีที่แล้ว +3

    #include
    int main();
    {
    Int number=2;
    (number % 2 == 0) ? Printf("the number is even") : printf("the number is odd");
    return 0 ;
    }

    • @Vincent-g4e3v
      @Vincent-g4e3v 3 วันที่ผ่านมา

      you like shortcuts

  • @sundeepchowdaryattaluri8797
    @sundeepchowdaryattaluri8797 2 ปีที่แล้ว +6

    Thanks for providing this useful and & well content for us....
    Code
    #include
    int main()
    {
    int a;
    scanf("%d", &a);

    (a %2 ==0) ?
    printf("%d is even", a):
    printf("%d is odd", a);
    }
    Ans for Question is C.

    • @benchmarkslab2005
      @benchmarkslab2005 2 ปีที่แล้ว

      One thing I can't understand bro. Why we used %d is even and %d is odd. If I used without %d it isn't working. But they didn't use %d in age calculator. Plzz explain bro

    • @musyabnahid8269
      @musyabnahid8269 2 หลายเดือนก่อน

      why C?

  • @user-nt4nm4fb3u
    @user-nt4nm4fb3u 11 หลายเดือนก่อน +1

    Great explanation as always! Thank you for everyone to make this happen.

    • @annettewairimu5542
      @annettewairimu5542 9 หลายเดือนก่อน

      how are you doing after two months?

  • @shohanurrahmanshoron1804
    @shohanurrahmanshoron1804 2 ปีที่แล้ว +3

    I tried this in front of my teacher and even he doesn't know about this operator. Thank U❤️❤️❤️

  • @sunangashilpakar3672
    @sunangashilpakar3672 3 ปีที่แล้ว +6

    Thankyou for explaining it so simply.. was waiting for your video ❤️

    • @annettewairimu5542
      @annettewairimu5542 9 หลายเดือนก่อน

      how are you doing after two years in programming?

  • @kankarlabharath6819
    @kankarlabharath6819 2 ปีที่แล้ว +6

    Mam your explanation is very good and nice, can you make a tutorial videos on Data structures and algorithms in good explanation based on c language.

  • @alirezaz9896
    @alirezaz9896 2 ปีที่แล้ว +2

    the best C language tutorial👌👌👌

  • @dede01706
    @dede01706 27 วันที่ผ่านมา

    Seeing the video in 2024, It's been a while since I've stopped learning C and did not know the language evolved like that. At least, I did not know, back in 2016, these features were available in C. Thank you

  • @mdsahil2203
    @mdsahil2203 3 ปีที่แล้ว +6

    Thanks for providing " Good quality "content
    By the way answer is option C

    • @shreyasy9164
      @shreyasy9164 2 ปีที่แล้ว +2

      why c

    • @shreyasy9164
      @shreyasy9164 2 ปีที่แล้ว +7

      i think option B is corrrect

    • @mandip863
      @mandip863 2 ปีที่แล้ว +2

      @@shreyasy9164 yes boss b is ans

    • @dhanushs1802
      @dhanushs1802 2 ปีที่แล้ว +1

      @@shreyasy9164 in the option B, if you change 5>3 to 3>5 , result will be 0 instead the result should be 3. So C is the answer.

    • @monalisabanra2733
      @monalisabanra2733 ปีที่แล้ว +1

      b can also be the answer i checked it

  • @qarikhalidwaheed1643
    @qarikhalidwaheed1643 ปีที่แล้ว +2

    Thanks for explaining this code simply

  • @pristinewalek4578
    @pristinewalek4578 3 ปีที่แล้ว +5

    Beautiful 🤩
    Thank you for explaining it so well

  • @SANJAYR-yy1zg
    @SANJAYR-yy1zg 10 หลายเดือนก่อน +20

    Answer is option c
    Result=5>3 ? 5 : 3;

    • @musyabnahid8269
      @musyabnahid8269 2 หลายเดือนก่อน +1

      why its not B?

    • @AsirPurchase
      @AsirPurchase หลายเดือนก่อน +1

      @@musyabnahid8269 Because as per the Required Program variable "result" must be assigned with 5 if 5 is greater than 3 and if false it must be assigned the value of 3.

    • @Bhavishyasoni-r6b
      @Bhavishyasoni-r6b 12 วันที่ผ่านมา

      @@AsirPurchase right bro 😃

  • @sayalikhairnar3211
    @sayalikhairnar3211 2 ปีที่แล้ว

    The great teacher of c programing

  • @ahmed_fsi
    @ahmed_fsi 2 ปีที่แล้ว +1

    Thank you! I didn't think it would be that easy to learn.

  • @venkatasumanth3027
    @venkatasumanth3027 2 ปีที่แล้ว +1

    ur way of teaching is exlent.....

  • @amayaamarasinghe5838
    @amayaamarasinghe5838 2 ปีที่แล้ว +2

    Thank you! The explanation is so useful!!!

  • @laxmanpeddi9714
    @laxmanpeddi9714 3 ปีที่แล้ว +7

    (option c)...........cool and clear content by progrmizzzz.....plz keep going......

    • @shreyasy9164
      @shreyasy9164 2 ปีที่แล้ว +1

      why c??????

    • @pretty_you2243
      @pretty_you2243 2 ปีที่แล้ว

      @@shreyasy9164 5>3? Is a condition. After evaluating the condition, value will be assigned to result variable as either 5 or 3.

  • @ashucloud
    @ashucloud 19 วันที่ผ่านมา +1

    Thank You!!

  • @qarikhalidwaheed1643
    @qarikhalidwaheed1643 ปีที่แล้ว +1

    It's going super good because of you explaining💞💕

  • @benjaminhuka7434
    @benjaminhuka7434 2 ปีที่แล้ว +2

    wonderful explaination, thank you!

  • @rubakvanitha8164
    @rubakvanitha8164 ปีที่แล้ว +1

    Thank you for your happy programming for us🎉

  • @onic9623
    @onic9623 ปีที่แล้ว +1

    Option C : result = 5> 3 ? 5 : 3;
    -----------------------------------------------------------
    #include
    int main()
    {
    int num;
    printf("Enter A Number: ");
    scanf("%d", &num);
    (num % 2 == 0) ? printf("Even") : printf("Odd");
    return 0;
    }

  • @ludowithsanjay
    @ludowithsanjay 2 ปีที่แล้ว +1

    Thank you🙏 mam. Your teaching quality is awesome👏

  • @qarikhalidwaheed1643
    @qarikhalidwaheed1643 ปีที่แล้ว +1

    ❤❤❤thank you for explaining it so easily❤❤❤

  • @igwilochimaobi2823
    @igwilochimaobi2823 หลายเดือนก่อน

    This was really helpful

  • @adityasharma3947
    @adityasharma3947 ปีที่แล้ว +7

    B as we have to print Result = 5
    but in C the value of just 5 is will be as output

  • @yunandaraung2556
    @yunandaraung2556 2 ปีที่แล้ว +1

    Thank you so much for such wonderful explanation!

    • @annettewairimu5542
      @annettewairimu5542 9 หลายเดือนก่อน +1

      how are you doing after 1 year in programming?

  • @chimmy832
    @chimmy832 3 หลายเดือนก่อน

    The correct answer is A, since the remainder of the modulus 5%2 is 1 making it not equal to 0. However, there is an exclamation mark before the parenthesis which means NEGATION or NOT, making it like this "1 is not equal to 0" or !1==0 in C language) which would be TRUE. That's why the answer is A. Inside if.
    If there is no negation or the symbol exclamation mark, the answer would be false which would be letter B. Inside else.

  • @nihatdonmzov4166
    @nihatdonmzov4166 2 ปีที่แล้ว +1

    Great video. Thank you so much

  • @eliskaellagalikova3251
    @eliskaellagalikova3251 2 ปีที่แล้ว +1

    I am going to write a test about this tomorrow🙄but I finally understant🥳

  • @seabasschukwu6988
    @seabasschukwu6988 ปีที่แล้ว

    GREAT EXPLANATION!

  • @unruly_ronin
    @unruly_ronin ปีที่แล้ว +2

    Subscribed coz you guys are brilliant and have a great presentation style
    Edit: Answer is C

  • @miarose5382
    @miarose5382 3 ปีที่แล้ว +1

    was waiting for you mam ... please upload the next video soon

  • @Darkness-898
    @Darkness-898 7 หลายเดือนก่อน +1

    PROGRAMMING TASK:
    #include
    int main() {
    int num;
    printf("Enter number here: ");
    scanf("%d", &num);
    (num%2==0)?printf("The number is even."):printf("The number is odd.");
    return 0;
    }
    PROGRAMIZ QUIZ ANSWER: Option(B) 5>3?5:3;

  • @kam-sc9gs
    @kam-sc9gs ปีที่แล้ว

    Ma'am thank you so much, I really appreciate ur work, and it really help me so much❤

  • @Sickpisspakh23971
    @Sickpisspakh23971 ปีที่แล้ว

    Thank you, padma ❤

  • @mojo7281
    @mojo7281 9 หลายเดือนก่อน

    Programming Task:
    #include
    #include
    int main() {
    int number;
    printf("Enter Number: ");
    scanf("%d", &number);
    (number % 2==0) ? printf("EVEN #") : printf("ODD #");
    return 0;
    }

  • @ejoshtech5358
    @ejoshtech5358 2 ปีที่แล้ว +1

    How is the flow chart drawn?
    But is this advisable to use in an exam

  • @fountain9886
    @fountain9886 ปีที่แล้ว +1

    #include
    int main (){
    int num ;
    printf("Enter a number :");
    scanf("%d", &num);
    if ( num % 2 == 0){
    printf("The number is even.");
    }
    else if (num % 2 != 0){
    printf("The number is odd.");
    }

    return 0;
    }
    it is coded in the common style.

  • @Ech-chatouiMohammed
    @Ech-chatouiMohammed 4 หลายเดือนก่อน

    VERY GREAT CONTENT

  • @clarencelucius9085
    @clarencelucius9085 11 หลายเดือนก่อน

    excellent teacher

  • @harshchauhan4945
    @harshchauhan4945 3 หลายเดือนก่อน +1

    option B.(5>3)? 5:3;

  • @bekmirzo_berdimurodov
    @bekmirzo_berdimurodov 8 หลายเดือนก่อน

    6:20 the answer is C

  • @raakshas5547
    @raakshas5547 2 ปีที่แล้ว +1

    Mam, aapke liye chand taare tod ke laa sakta hoo.......coding challenge to keya chiz hai ? Ye lo answer....
    #include
    #include
    int main()
    {
    int num;
    printf("Enter the age
    ");
    scanf("%d",&num);
    (num%2==0)?printf("The number is even"):printf("The number is odd");
    return 0;
    }
    Aapka 2nd question ka answer hai option B.

  • @aaronbenjamin3143
    @aaronbenjamin3143 3 ปีที่แล้ว

    I have a question can I? create a program to integrate into a program like array and basic computer calculator etc. I hope you can answer thank you

  • @gogulram2551
    @gogulram2551 2 ปีที่แล้ว +1

    program is #include
    int main() {
    int num;
    printf("enter the number: ");
    scanf("%d", &num);
    (num % 2 == 0) ? printf("number is even") :
    printf("number is odd");

    return 0;
    }

  • @AFCOE
    @AFCOE ปีที่แล้ว

    Hello madam.
    Mind is displaying "number is even" when I haven't insert anything.
    int number;
    (number%2==0)? printf("number is even"):
    printf("number is odd");

  • @zonekenne5329
    @zonekenne5329 ปีที่แล้ว

    why do I get an error when I try to do the operation with a "double" data type. I expected the integer to be converted to double since the double is greater than the int in the ranking

  • @williamowusu7778
    @williamowusu7778 2 ปีที่แล้ว +1

    Thanks 👍

  • @JoeMama-zc8ub
    @JoeMama-zc8ub 3 ปีที่แล้ว +1

    The real MVP

  • @WWhitewalker
    @WWhitewalker 3 ปีที่แล้ว +1

    its going good !!

  • @countrysideshowyaigrock4689
    @countrysideshowyaigrock4689 ปีที่แล้ว

    Thank you very much!!

  • @subhajitNath0
    @subhajitNath0 3 ปีที่แล้ว +1

    good quality 😊

  • @freehug071
    @freehug071 2 ปีที่แล้ว

    #include
    int main()
    {
    int number = 3;
    (number % 2==0) ? printf("the number is odd") : printf("the number is even");
    return 0;
    }

  • @spoilermedia-h6i
    @spoilermedia-h6i 10 หลายเดือนก่อน

    #include
    int main() {
    double num1=1;
    double num2=3,result;
    result=1+3;
    printf("enter the number: ");
    scanf("%d", &result);
    (result>=4)? printf("the number is even"):printf("the numer is odd");
    return 0;
    }

  • @yunghan1754
    @yunghan1754 2 หลายเดือนก่อน

    6:21 answer is C C C

  • @MagaScampini
    @MagaScampini 9 หลายเดือนก่อน +1

    I think the answer is B. Because the condition in the if...Else statement is if (5 > 3) instead of if the result = (5 > 3); for in that case the right answer would be C. Can anyone confirm?

  • @DicksonEsibitar
    @DicksonEsibitar 7 หลายเดือนก่อน

    Love it❤

  • @VarshiniSDevadiga-h5q
    @VarshiniSDevadiga-h5q 2 หลายเดือนก่อน

    option c is the correct answer

  • @balashebjadhav977
    @balashebjadhav977 ปีที่แล้ว +1

    The answer is option C)

  • @haydenawc7189
    @haydenawc7189 11 หลายเดือนก่อน

    i’m learning sm

  • @starknow1345
    @starknow1345 ปีที่แล้ว

    programming task answer
    void main(){
    int number;
    printf("enter number:");
    scanf("%d", &number);
    (number %2==0)? printf("the number is even"): printf("the number is odd");
    }

    • @starknow1345
      @starknow1345 ปีที่แล้ว

      dont forget to include the library header

  • @sara-cq8ev
    @sara-cq8ev ปีที่แล้ว

    // Online C compiler to run C program online
    #include
    int main() {
    int number;
    printf("enter your number ");
    scanf("%d",&number);
    (number %2==0)? printf("num is even") : printf("nub is odd");

    return 0;
    }

  • @MercylineNyaboke-b9x
    @MercylineNyaboke-b9x ปีที่แล้ว

    Nice❤❤❤

  • @based1712
    @based1712 ปีที่แล้ว +1

    The answer is option B.

  • @srikanthkotaru515
    @srikanthkotaru515 ปีที่แล้ว

    // Online C compiler to run C program online
    #include
    int main() {
    // Write C code here
    int number = 11;
    int result = (number % 2 == 0) ? printf("it is even") : printf("it is odd");
    return 0;
    }

  • @lakshanj.kumara7648
    @lakshanj.kumara7648 ปีที่แล้ว

    #include
    int main(){
    int num=3;
    (num%2==0)? printf("Number is even"):printf("Number is odd");
    return 0;
    }

  • @avdeshsingh001
    @avdeshsingh001 2 ปีที่แล้ว

    Thanks ma'am

  • @naveenperspective
    @naveenperspective 11 หลายเดือนก่อน +1

    Option c

  • @abercharity8023
    @abercharity8023 ปีที่แล้ว

    // Online C compiler to run C program online
    #include
    int main() {
    int num =25;
    (num%2)? printf("The numberis odd") : printf("The number is even");
    return 0;

  • @ogunlalusarah1138
    @ogunlalusarah1138 ปีที่แล้ว

    good work

  • @ebubeanieke2072
    @ebubeanieke2072 ปีที่แล้ว

    C is the right answer

  • @aboutouruniverse3834
    @aboutouruniverse3834 ปีที่แล้ว

    the answers people are giving for the programming task that is given is kind of out of the question because she said that we should assign a value to the variable number but no one is doing that,i am trying to follow the instruction that she gave but its damn hard

    • @Kkienut
      @Kkienut ปีที่แล้ว

      #include
      int main () {
      int x = 3;
      (x%2 == 0) ?
      printf("The number is even"):
      printf("The number is odd");
      return 0;
      }

  • @RiyaShorts18
    @RiyaShorts18 2 ปีที่แล้ว +1

    Correct ans is B

  • @jagavardhan576
    @jagavardhan576 9 หลายเดือนก่อน

    Answer for the que?

  • @Girma_Chew
    @Girma_Chew 2 ปีที่แล้ว

    I hope this will be the correct answer, I have tried it on online compiler provided by Programiz.
    /*This is a program to check whether a number is EVEN or ODD by enquiring an input from a user.*/
    #include
    int main(){
    int number;

    printf("Enter any number!
    ");
    scanf("%d", &number);

    (number%2==0) ? printf("The number %d is Even.",number) : printf("The number %d is Odd.",number);

    return 0;
    }
    //Thank U for helping us.

  • @christlike8712
    @christlike8712 2 ปีที่แล้ว

    #include
    int main()
    {
    int num = 4;

    (num%2==0)?
    printf("This is an even number"):
    printf("This is an odd number");
    return 0;
    }

  • @chimmy832
    @chimmy832 3 หลายเดือนก่อน

    int main() {
    // Write C code here
    int num;
    printf("Enter number: ");
    scanf("%d", &num);
    if (num>0){
    printf("The number %d is a positive number.", num);
    }
    else if (num

  • @David_Chijioke
    @David_Chijioke 7 หลายเดือนก่อน

    thanks a lot

  • @nagarajan4687
    @nagarajan4687 ปีที่แล้ว

    int a;
    printf("Enter the a:");
    scanf("%d",&a);
    (a%2==0)?printf("even number"):printf("odd number");
    return 0;

  • @behailus-tube5024
    @behailus-tube5024 9 หลายเดือนก่อน

    programming task
    int number;
    printf("Enter a number: ");
    scanf("%d", &number);

    int resulte = (number%2 == 0) ? printf("
    an even number") : printf("
    an odd number");

  • @mohammedshajith4012
    @mohammedshajith4012 23 วันที่ผ่านมา

    Thank youu

  • @KageraTanzania
    @KageraTanzania 19 วันที่ผ่านมา

    Answer is C. result = 5 > 3 ? 5 : 3;

  • @brianochieng7371
    @brianochieng7371 2 หลายเดือนก่อน

    Looks like i am revising javascript

  • @arhitjoseph9681
    @arhitjoseph9681 2 ปีที่แล้ว +1

    //division method
    #include
    int main()
    {
    int num;
    printf("Enter the number:");
    scanf("%d",&num);
    (num/2==0)? printf("It is an even number") : printf("It is an odd number");
    return 0;
    }

    • @timetocreate62
      @timetocreate62 2 ปีที่แล้ว +2

      I think you should write (num%2==0), because in that way we are looking at the number that is left after dividing, no the actual result.

  • @bhavanaanu9076
    @bhavanaanu9076 3 ปีที่แล้ว +3

    Option C mam!!

    • @shreyasy9164
      @shreyasy9164 2 ปีที่แล้ว +1

      WHY C ???

    • @soysob9490
      @soysob9490 2 ปีที่แล้ว

      @@shreyasy9164 you solv the ternary operator ! you must ans in option c

  • @ndikevinetawe8751
    @ndikevinetawe8751 8 หลายเดือนก่อน

    C is the answer

  • @ravikiranhs8464
    @ravikiranhs8464 5 หลายเดือนก่อน

    It just shows error in char line

  • @jerseyclubbydn153
    @jerseyclubbydn153 ปีที่แล้ว

    #include
    int main() {
    int number = 21;
    (number%2==0) ? printf("Even ") :printf("Odd");
    return 0;
    }

  • @Shiiro03
    @Shiiro03 ปีที่แล้ว

    int main() {
    int num;
    scanf("%d", &num);
    ( num % 2 == 0) ? printf("Number is even") : printf("Number is odd");
    return 0;

  • @gayathri0301
    @gayathri0301 7 หลายเดือนก่อน

    C option for quiz mam