# Programming Lession 101 - 200401 ## Exercise ### Conditional Statement 1. Write a C# Sharp program to accept two integers and check whether they are equal or not. Test Data Input 1st number: 5 Input 2nd number: 5 Expected Output : 5 and 5 are equal 2. Write a C# Sharp program to check whether a given number is even or odd. Test Data : 15 Expected Output : 15 is an odd integer 3. Write a C# Sharp program to check whether a given number is positive or negative. Test Data : 14 Expected Output : 14 is a positive number 4. Write a C# Sharp program to find whether a given year is a leap year or not. Test Data : 2016 Expected Output : 2016 is a leap year. 5. Write a C# Sharp program to read the age of a candidate and determine whether it is eligible for casting his/her own vote. Test Data : 21 Expected Output: Congratulation! You are eligible for casting your vote. 6. Write a C# Sharp program to read the value of an integer m and display the value of n is 1 when m is larger than 0, 0 when m is 0 and -1 when m is less than 0. Test Data : -5 Expected Output: The value of n = -1 7. Write a C# Sharp program to accept the height of a person in centimeter and categorize the person according to their height. Test Data : 135 Expected Output : The person is Dwarf. 8. Write a C# Sharp program to find the largest of three numbers. Test Data : Input the 1st number :25 Input the 2nd number :63 Input the 3rd number :10 Expected Output : The 2nd Number is the greatest among three 9. Write a C# Sharp program to accept a coordinate point in an XY coordinate system and determine in which quadrant the coordinate point lies. Test Data : Input the value for X coordinate :7 Input the value for Y coordinate :9 Expected Output : The coordinate point (7,9) lies in the First quadrant. 10. Write a C# Sharp program to find the eligibility of admission for a professional course based on the following criteria: Marks in Maths >=65 Marks in Phy >=55 Marks in Chem>=50 Total in all three subject >=180 or Total in Math and Subjects >=140 Test Data : Input the marks obtained in Physics :65 Input the marks obtained in Chemistry :51 Input the marks obtained in Mathematics :72 Expected Output : The candidate is eligible for admission. ### Loop 1. Write a program in C# Sharp to display the first 10 natural numbers. Expected Output : 1 2 3 4 5 6 7 8 9 10 2. Write a C# Sharp program to find the sum of first 10 natural numbers. Expected Output : The first 10 natural number is : 1 2 3 4 5 6 7 8 9 10 The Sum is : 55 3. Write a program in C# Sharp to display n terms of natural number and their sum.Go to the editor Test Data : 7 Expected Output : The first 7 natural number is : 1 2 3 4 5 6 7 The Sum of Natural Number upto 7 terms : 28 4. Write a program in C# Sharp to read 10 numbers from keyboard and find their sum and average. Test Data : Input the 10 numbers : Number-1 :2 ... Number-10 :2 Expected Output : The sum of 10 no is : 51 The Average is : 5.100000 5. Write a program in C# Sharp to display the cube of the number upto given an integer. Test Data : Input number of terms : 5 Expected Output : Number is : 1 and cube of the 1 is :1 Number is : 2 and cube of the 2 is :8 Number is : 3 and cube of the 3 is :27 Number is : 4 and cube of the 4 is :64 Number is : 5 and cube of the 5 is :125 6. Write a program in C# Sharp to display the multiplication table of a given integer. Test Data : Input the number (Table to be calculated) : 15 Expected Output: ``` 15 X 1 = 15 ... ... 15 X 10 = 150 ``` 7. Write a program in C# Sharp to display the multiplication table vertically from 1 to n. Test Data : Input upto the table number starting from 1 : 8 Expected Output: Multiplication table from 1 to 8 1x1 = 1, 2x1 = 2, 3x1 = 3, 4x1 = 4, 5x1 = 5, 6x1 = 6, 7x1 = 7, 8x1 = 8 ... 1x10 = 10, 2x10 = 20, 3x10 = 30, 4x10 = 40, 5x10 = 50, 6x10 = 60, 7x10 = 70, 8x10 = 80 8. Write a program in C# Sharp to display the n terms of odd natural number and their sum. Test Data Input number of terms : 10 Expected Output : The odd numbers are :1 3 5 7 9 11 13 15 17 19 The Sum of odd Natural Number upto 10 terms : 100 9. Write a program in C# Sharp to display the pattern like right angle triangle using an asterisk. The pattern like : ``` * ** *** **** ``` 10. Write a program in C# Sharp to display the pattern like right angle triangle with a number. The pattern like : ``` 1 12 123 1234 ```