Conditional Constructs Programming Example C#

example
In this chapter you will learn:

  • How to use conditional constructs in C# programming?
Qu 1: Write a program in which accept a number from the user and identify whether the number is even or odd.
Answer:

  • Output

    Enter your number :     56
    56 is Even Number
    __

     

    Qu2:Write a program in which accept a number from the user between 1 to 7 and display corresponding days starting with Monday.

    Hint: Use switch case

    Answer:

    Output

    Enter your option <1-7> for days. 1 for Monday : 9
    Invalid option. Please try againEnter your option <1-7> for days. 1 for Monday : 2
    Tuesday
    __

     

    Summary

    In this chapter you learned the some programming examples of conditional constructs in c# programming. In next chapter, some exercises are given. It is recommended you to must do the conditional constructs exercise honestly.


    Leave a Reply

    Your email address will not be published. Required fields are marked *