Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, 22 March 2017

Simple program


In this blog, we are going to code simple program that usually asked. Many of us get confused between loops and conditions. And it is also one of the most asked interview questions.
 
Simple program by www.imaginationhunt.com
Simple program

In the table given below, we have listed out various simple programs.

Note: If you are new to C# and Console Application. Try to code First C# Program

Note: Read articles on how to use Loops and Conditions.

Let’s find out a simple and easy way to code these programs.

S.no.
Simple Program
1.     

Source code to check whether a number is even or odd

Number: 5, is Odd.
Number: 10, is Even.

Click to view string code

2.     

Source code to check whether a number is even or odd using ternary or conditional operator

Number: 5, is Odd.
Number: 10, is Even.

Click to view string code

3.     

Source code to print even and odd number upto n

Even number upto: 20 are:
2 4 6 8 10 12 14 16 18 20
Odd number upto: 20 are:
1 3 5 7 9 11 13 15 17 19

Click to view string code

4.     

Source code to swap number using three variables

Before swapping a is : 8
Before swapping b is : 6
After swapping a is : 6
After swapping b is : 8

Click to view string code

5.     

Source code to swap number using two variables

Before swapping a is : 8
Before swapping b is : 6
After swapping a is : 6
After swapping b is : 8

Click to view string code

6.     

Source code to check whether a number is prime or not

-1
Smallest prime number is 2
39
Not prime number

Click to view string code

7.     

Source code to print next prime number

Enter a number: 11
Next prime number: 13

Click to view string code



For any query, comment us below.

Previous – String based program

Next - Simple program #1


Click
imagination hunt to read latest blogs.

Keep learning and sharing...

No comments:

Post a Comment

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...