Monday, August 31, 2020

4.WRITE AN ALGORITHM TO CALCULATE AND DISPLAY OF THE FOLLOWING SERIES : 1x2/3+3x4/5+5x6/7.... UPTO N

 

START

STEP 1: Declare the variable n ,i as integer as c as double

STEP 2: Initialize n=c=0 and i=1,k=1

STEP 3: Input the value of n

STEP 4: If k<=n then c=c+(i x ((i+1)/(i+2))) ,goto step 5 else goto 6

STEP 5 : Increment the value of i by 2 and k by 1  and goto step 4

STEP 6 : Display the value of c

END

 3.WRITE AN ALGORITHM TO CALCULATE AND DISPLAY OF THE FOLLOWING SERIES : 1/2-2/3+3/4-4/5+5/6.... UPTO N 

 START

STEP 1: Declare the variable n and i as integer. and c as double

STEP 2: Initialize n=c=0 and i=1

STEP 3: Input the value of n

STEP 4: If i<=n then Goto Step 5 else Goto Step 7

STEP 5: If  i %2 =0 then c=c-(i/(i+1))  , Goto Step 6 else c=c+(i/(i+1)) , Goto Step 6

STEP 6 : Increment the value of i by 1 and Goto Step 4

STEP 7 : Display the value of c

END

 2.WRITE AN ALGORITHM TO CALCULATE AND DISPLAY OF THE FOLLOWING SERIES : 1-2+3-4+5.... UPTO N 

 

 START

STEP 1: Declare the variable n ,c and i as integer.

STEP 2: Initialize n=c=0 and i=1

STEP 3: Input the value of n

STEP 4: If i<=n then Goto Step 5 else Goto Step 7

STEP 5: If  i %2 =0 then c=c-i ,Goto Step 6 else c=c+i , Goto Step 6

STEP 6 : Increment the value of i by 1 and Goto Step 4

STEP 7 : Display the value of c

END

1.WRITE AN ALGORITHM TO CALCULATE AND DISPLAY OF THE FOLLOWING SERIES :  

    1x2+2x3+3x4+......nx(n+1) 

 

START 

STEP 1: Declare the variable n ,c and i as integer.

STEP 2: Initialize n=c=0 and i=1

STEP 3: Input the value of n 

STEP 4: If i<=n then c=c+(i x (i+1)) ,goto step 5 else goto 6

STEP 5 : Increment the value of i by 1 and goto step 4 

STEP 6 : Display the value of c

END

Thursday, August 13, 2020

                                  ALGORITHM

                           -----------------------------

 4.WRITE AN ALGORITHM TO INPUT 2 NUMBERS AND DISPLAY THE LARGEST EVEN NUMBER.


START

STEP 1: DECLARE THE VARIABLE X,Y AS INTEGER.

STEP2: INPUT THE VALUE OF X AND Y

STEP 3: IF (X% 2=0 AND Y%2=0 AND X=Y ) THEN  PRINT "BOTH THE NUMBERS ARE EVEN AND EQUAL "('%' IS USED TO RETURN THE REMAINDER IN CASE OF DIVISION), GO TO END

STEP 4: IF (X%2=0 AND X>Y) THEN PRINT X,"IS LARGEST EVEN"

STEP 5 : IF (Y%2=0 AND Y>X ) THEN PRINT Y,"IS LARGEST EVEN"


END



                                  ALGORITHM

                           -----------------------------

 3.WRITE AN ALGORITHM TO INPUT A NUMBER AND CHECK WHETHER THE NUMBER IS ODD OR EVEN.


START

STEP 1: DECLARE THE VARIABLE X AS INTEGER.

STEP2: INPUT THE VALUE OF X

STEP 3: IF X% 2=0 THEN PRINT X,"IS EVEN" ELSE PRINT X,"IS ODD" ('%' IS USED TO RETURN THE REMAINDER IN CASE OF DIVISION)

END


                  ALGORITHM 

             ---------------------------


2.WRITE AN ALGORITHM TO INPUT 3 NUMBERS , DISPLAY ONLY THOSE NUMBERS WHICH ARE DIVISIBLE BY 8 .

 

START

STEP 1: DECLARE THE VARIABLES X,Y AND Z AS INTEGER.

STEP 2: IF X % 8 = 0 THEN PRINT X,"IS DIVISIBLE BY 8" ('%' IS  USED TO RETURN  THE REMAINDER IN CASE OF DIVISION)

STEP 3: IF Y % 8 = 0 THEN PRINT Y,"IS DIVISIBLE BY 8"

STEP 4:  IF Z % 8 = 0 THEN PRINT Z,"IS DIVISIBLE BY 8" 

END

 

                    ALGORITHM 

             ---------------------------


1.WRITE AN ALGORITHM TO INPUT 2 NUMBERS AND DISPLAY THE LARGEST NUMBER .


ANSWER :

 START

STEP 1: DECLARE THE VARIABLES X AND Y AS INTEGER.

STEP 2: INPUT THE VALUES OF X  AND Y .

STEP3 : IF X=Y THEN PRINT "BOTH ARE EQUAL", GO TO END

STEP 4 IF X>Y THEN PRINT X,"IS LARGEST" ELSE PRINT Y,"IS LARGEST"

END


  3.WAP IN JAVA TO INPUT THREE NUMBERS AND COUNT HOW MANY OF THEM ARE EVEN .   import java.util.*; class Prog {   public static ...