Computer Science, asked by rimjhimyadav72, 4 months ago

Find the output of the following code:

int s = 0;

if ( s <= 13 ):

if ( s % 2 == 2 ):

print(“Colour code RED”)

else:

print(“Colour code BLUE”)

print(“New Stripe”)

s = s + 1;

<1>

Answers

Answered by Saibabach4gmailcom
0

Answer:

Subject: Informatics Practices HOLIDAYS HOMEWORK Grade XII

1. Compare the following

(1) if and a ? : Operator.

(2) while and do.. while loop

2. Given the following code fragment:

if (a==0)

System.out.print ln (“Zero”);

if (a==1)

System.out.print ln (“One”);

if (a==2)

System.out.print ln (“Two”);

if (a==3)

System.out.print ln (“Three”);

Write an alternative code that saves on number of comparisons.

3. Rewrite the following fragment using switch:

if (ch== ‘E’)

eastern++ ;

if (ch== ‘W’)

western++ ;

if (ch== ‘N’)

northern++ ;

if (ch== ‘S’)

southern++ ;

else

unknown++ ;

4. Write the syntax and purpose of a switch statement.

5. When does an if statement prove more advantageous over a switch statement?

6. Why is it suggested to put a break statement after the last case statement in a switch

even though it is not needed syntactically?

7. Rewrite the code given in question 3 using switch?

8. Rewrite the following set of if-else statements in terms of switch-case statements:

(a) char code ;

code = character.readChar();

if (code == ‘A’)

System.out.print ln (“Accountant”);

else if (code == ‘C’ ll code == ‘G’)

System.out.print ln (“Grade IV”);

else if (code == ‘F’)

System.out.print ln (“Financial Advisor”);

Answered by Anonymous
0

Given:

Co - ordinates of point A = (-1 , 7)

Co - ordinates of point B = (4, - 3)

Ratio in which P divides A and B is 2:3.

⠀⠀⠀⠀⠀⠀⠀

To find:

Co - ordinates of point P ?

⠀⠀⠀⠀⠀⠀⠀

Solution:

⠀⠀⠀⠀⠀⠀⠀

☯ Let coordinates of point P be (x,y).

⠀⠀⠀⠀⠀⠀⠀

\dag\;{\underline{\frak{Using\;section\;formula\;:}}}

⠀⠀⠀⠀⠀⠀⠀

\star\;{\boxed{\sf{\purple{(x,y) = \bigg( \dfrac{m_2 x_1 + m_1 x_2}{m_1 + m_2}\;,\; \dfrac{m_2 y_1 + m_1 y_2}{m_1 + m_2} \bigg)}}}}\\ \\

\dag\;{\underline{\frak{Putting\;values,}}}

⠀⠀⠀⠀⠀⠀⠀

:\implies\sf (x,y) = \bigg( \dfrac{3 \times (-1) + 2 \times 4}{2 + 3}\;,\; \dfrac{3 \times (7) + 2 \times (-3)}{2 + 3} \bigg)\\ \\

:\implies\sf (x,y) = \bigg( \dfrac{8 - 3}{5}\;,\; \dfrac{-6 + 21}{5}\bigg)\\ \\

:\implies\sf (x,y) = \bigg( \dfrac{5}{5}\;,\; \dfrac{15}{5}\bigg)\\ \\

:\implies\sf \pink{(x,y) = (1 , 3)}\;\bigstar\\ \\

\therefore\;{\underline{\sf{Thus,\; Coordinates\;of\;point\;P\;are\; {\textsf{\textbf{(1,3)}}}.}}}

⠀⠀⠀━━━━━━━━━━━━━━━━━━━━━━━━━

\qquad\qquad\boxed{\bf{\purple{\mid{\overline{\underline{\bigstar\:More\;to\;know:}}}}\mid}}\\\\

Formula that is used to find the distance between two points :

⠀⠀⠀⠀⠀⠀⠀

Distance Formula = \sf \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

Similar questions