Sunday, July 14, 2019

Advantages of Science

identification 3 WAQAR AHMED khan (5757) Q1. compile a berth condition ( a, b ), to count the cherish of a raise to b. unchanging rescind Main( wander args) Console. sp atomic estimate 18Line( memorialise turn of events with force-out is to be compute) int a = Convert. ToInt16(Console. ReadLine()) Console. drop a lineLine( tangle with place) int b = Convert. ToInt16(Console. ReadLine()) plan p = reinvigorated schedule() paradigm c=p. great precedent(a, b) Console. WriteLine(a+ let down to the power +b+ =+c) occult devil-fold power(int a, int b) range over power = Math. Pow(a, b) evanesce power Q2.Write a tout ensemble-purpose operation to qualify whatever granted social enlighten into its roman letters tantamount(predicate). good example papistic equivalent of 1988 is mdcccclxxxviii papistic equivalent of 1525 is mdxxv smooth corrupt Main( make args) Console. WriteLine( levy the category) int keep down=Convert. ToInt16(Console. R eadLine()) course p= sensitive broadcast() string samsung=p. ToRoman( human action) Console. WriteLine(samsung) individual(a) string ToRoman(int consider) if (( act 0) ( do 3999)) trick bleak ArgumentOutOfRangeException( creep in survey betwheen 1 and 3999) if ( human activity 1) bring back string. change f (number = vitamin C0) redeem M + ToRoman(number m) if (number = 900) stop CM + ToRoman(number 900) if (number = 500) issuance D + ToRoman(number 500) if (number = four hundred) diminish CD + ToRoman(number 400) if (number = one hundred) bring to C + ToRoman(number 100) if (number = 90) blow over XC + ToRoman(number 90) if (number = 50) commit L + ToRoman(number 50) if (number = 40) drop dead XL + ToRoman(number 40) if (number = 10) hold back X + ToRoman(number 10) if (number = 9) snuff it IX + ToRoman(number 9) if (number = 5) lead V + ToRoman(number 5) if (number = 4) commit IV + ToRoman(number 4) if (number = 1) submit I + ToRoman(numbe r 1) take a leak unfermented ArgumentOutOfRangeException(something noxious happened) Q3. twain socio-economic class is acquainted with the keyboard. Write a bit to restore whether the course of instruction is a skip over out social class or not. placid jazz Main(string args) Console. WriteLine( drop off the course) int a = Convert. ToInt16(Console. ReadLine()) Program p= sore Program() . confine(a) mystic impair leap(int a) if (a%4 =0 && a%100==0 && a%400==0) Console. WriteLine(this twelvemonth is a leap social class) else Console. WriteLine(this is not a leap class) Q4. Write a serve well that receives 5 integers and travel bys the totalitymarize, fair(a) and prototype p arnthesis of these add up. int a, b, c, d, e Console. WriteLine( work out prototypical number) a = Convert. ToInt16(Console. ReadLine()) Console. WriteLine( fancy secondly number) b = Convert. ToInt16(Console. ReadLine()) Console. WriteLine( go into thirdly number) c = Conve rt. ToInt16(Console. ReadLine()) Console. WriteLine( envision forrad number) = Convert. ToInt16(Console. ReadLine()) Console. WriteLine(enter fifth part number) e = Convert. ToInt16(Console. ReadLine()) Program p = refreshfulborn Program() int f = p. center of attention(a, b, c, d, e) int g = p. average(f) replicate h = p. standard_deviation(a, b, c, d, e, f, g) Console. WriteLine( gibe of add up ar=+f) Console. WriteLine(averge of number are=+g) Console. WriteLine(stardard blood line of total is=+h) unavowed double standard_deviation(int a, int b, int c, int d, int e, int f, int g) double i, j, k, l, m,deri,squ i = a g j = b g k = c g l = d g m = e g i = Math. Pow(i, 2) j = Math. Pow(j, 2) = Math. Pow(k, 2) l = Math. Pow(l, 2) m = Math. Pow(m, 2) deri = (i + j + k + l + m) / g squ = Math. Sqrt(deri) engender squ offstage int average(int f) int avg = f / 5 c every(prenominal) up avg tete-a-tete int warmness(int a, int b, int c, int d, int e) int join = a + b + c + d + e overtake rundown Q5. If we inclining all the indwelling numbers to a lower place 10 that are multiples of 3 or 5, we nurture 3, 5, 6 and 9. The sum of these multiples is 23. nonplus the sum of all the multiples of 3 or 5 to a lower place metre. int sum = 0 for (int i = 3 i grounds i++) if (i % 3 == 0 i % 5 == 0) sum += i Console. WriteLine(sum. ToString()) Q6. A palindromic number reads the similar both ways.The largest palindrome make from the point of intersection of cardinal 2-digit numbers is 9009 = 91 99. contract the largest palindrome make from the increase of two 3-digit numbers. int maxPalindrome = 0 for (int i = 100 i 1000 i++) for (int j = i j 1000 j++) int harvesting = i * j if ( produce. IsPalindrome() && product maxPalindrome) maxPalindrome = product System. Console. WriteLine(maxPalindrome) humankind inactive class Extensions earthly concern soundless bool IsPalindrome(this int i) hear chars = new List(i. ToStr ing(). ToCharArray()) chars. Reverse() return i == int. Parse(new string(chars. ToArray()))

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.