Friday, 8 July 2011

Pseudocode

//WRITE A PSEUDOCODE TO FIND THE SUM OF TWO NUMBERS.

begin
    numeric nNum1,nNum2,nSum
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    compute nSum=nNum1+nNum2
    display "SUM OF THESE NUMBER : " nSum
end

//WRITE A PSEUDOCODE TO FIND THE SUM OF THREE NUMBERS.

begin
    numeric nNum1,nNum2,nNum3,nSum
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    display "ENTER THE THIRD NUMBER : "
    accept nNum3
    nSum=nNum1+nNum2+nNum3
    display "SUM OF ALL THREE NUMBERS : " nSum
end

//WRITE A PSEUDOCODE TO FIND THE AREA OF RECTANGLE.

begin
    numeric nLen,nBrd,nAre
    display "ENTER THE LENGTH OF RECTANGLE : "
    accept nLen
    display "ENTER THE BREADTH OF RECTANGLE : "
    accept nBrd
    nAre=nLen*nBrd
    display "AREA OF RECTANGLE : " nAre
end

//WRITE A PSEUDOCODE TO FIND THE PERIMETER OF RECTANGLE.

begin
    numeric nLen,nBrd,nAre
    display "ENTER THE LENGTH OF RECGTANGLE : "
    accept nLen
    display "ENTER THE BREADTH OF RECTANGLE : "
    accept nBrd
    nAre=2*(nLen+nBrd)
    display "PERIMETER OF RECTANGLE : " nAre
end

//WRITE A PSEUDOCODE TO FIND THE AREA OF SQUARE.

begin
    numeric nSide, nArea
    display "ENTER THE SIDE OF SQUARE : "
    accept nSide
    nArea=nSide*nSide
    display "AREA OF SQUARE : " nArea
end

//WRITE A PSEUDOCODE TO FIND THE PERIMETER OF SQUARE.

begin
    numeric nSide,nPeri
    display "ENTER THE SIDE OF SQUARE : "
    accept nSide
    nPeri=nSide*nSide
    display "AREA OF SQUARE : " nPeri
end

//WRITE A PSEUDOCODE TO FIND THE AREA OF CIRCLE.

begin
    numeric nRad, nAre
    display "ENTER THE RADIUS OF CIRCLE : "
    accept nRad
    nAre = nRad*nRad*22/7
    display "AREA OF CIRCLE : " nAre
end

//WRITE A PSEUDOCODE TO FIND THE CIRCUMFERENCE OF CIRCLE.

begin
    numeric nRad,nCir
    display "ENTER THE RADIUS OF CIRCLE : "
    accept nRad
    nCir=2*nRad*22/7
    display "CIRCUMFERENCE OF CIRCLE : " nCir
end

//WRITE A PSEUDOCODE TO FIND THE AREA OF PARALLELOGRAM.

begin
    numeric nBase, nPerp, nArea
    display "ENTER THE BASE : "
    accept nBase
    display "ENTER THE PERPENDICULAR : "
    accept nPerp
    nArea=nBase*nPerp
    display "AREA OF PARALLELOGRAM : " nArea
end

//WRITE A PSEUDOCODE TO FIND THE AREA OF TRIANGLE.

begin
    numeric nBase, nHigh, nArea
    display "ENTER THE BASE OF TRIANGLE : "
    accept nBase
    display "ENTER THE HEIGHT OF TRIANGLE : "
    accept nHigh
    nArea=nBase*nHigh
    display "AREA OF TRIANGLE : " nArea
end

//WRITE A PSEUDOCODE TO FIND THE  AREA OF RHOMBUS.

begin
    numeric nDgn1, nDgn2, nArea
    display "ENTER THE LENGTH OF FIRST DIAGONAL : "
    accept nDgn1
    display "ENTER THE LENGTH OF SECOND DIAGONAL : "
    accept nDgn2
    nArea=nDgn1*nDgn2/2
    display "AREA OF RHOMBUS : " nArea
end

//WRITE A PSEUDOCODE TO FIND THE GREATEST OF TWO NUMBERS.

begin
    numeric nNum1, nNum2
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    if(nNum1>nNum2)
    begin
        display "GREATEST ONE : " nNum1
    end
    else
    begin
        display "GREATEST ONE : " nNum2
    end
end

//WRITE A PSEUDOCODE TO FIND THE GREATEST OF TWO NUMBERS USING TERNARY OPERATOR.

begin
    numeric nNum1, nNum2
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    nGone=(nNum1>nNum2)?nNum1:nNum2
    display "GREATEST ONE : " nGone
end

//WRITE A PSEUDOCODE TO FIND THE GREATEST OF THREE NUMBERS.

begin
    numeric nNum1,nNum2,nNum3
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    display "ENTER THE THIRD NUMBER : "
    accept nNum3
    if(nNum1>nNum2)
    begin
        if(nNum1>nNum3)
        begin
            display "GREATEST ONE : " nNum1
        end
        else
        begin
            display "GREATEST ONE : " nNum3
        end
    end
    else
    if(nNum2>nNum3)
    begin
        display "GREATEST ONE : " nNum2
    end
    else
    begin
        display "GREATEST ONE : " nNum3
    end
end
//WRITE A PSEUDOCODE TO FIND THE GREATEST OF THREE NUMBERS.

begin
    numeric nNum1, nNum2, nNum3
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    display "ENTER THE THIRD NUMBER : "
    accept nNum3
    if(nNum1>nNum2&&nNum1>nNum3)
    begin    
        display "GREATEST ONE : " nNum1
    end
    else
    if(nNum2>nNum3&&nNum1)
    begin
        display "GREATEST ONE : " nNum2
    end
    else
    if(nNum3>nNum2&&nNum3>nNum1)
    begin
        display "GREATEST ONE : " nNum3
    end
end

//WRITE A PSEUDOCODE TO FIND THE GREATEST OF THREE NUMBERS.

begin
    numeric nNum1, nNum2, nNum3
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    display "ENTER THE THIRD NUMBER : "
    accept nNum3
    Num=nNum1
    if(Num<nNum2)
    begin
        Num=nNum2
    end
    if(Num<nNum3)
    begin
        Num=nNum3
    end
    display "GREATEST ONE : " Num
end

//WRITE A PSEUDOCODE TO CHECK WHETHER THE ENTERED NUMBER IS EVEN OR ODD.

begin
    numeric nNum
    display "ENTER A NUMBER : "
    accept nNum
    if(nNum%2==0)
    begin
        display "EVEN"
    end
    else
    begin
        display "ODD"
    end
end

//WRITE A PSEUDOCODE TO CHECK EQUIVALENCE OF TWO NUMBERS. USE IF STATEMENT.

begin
    numeric nNum1, nNum2
    display "ENTER THE FIRST NUMBER : "
    accept nNum1
    display "ENTER THE SECOND NUMBER : "
    accept nNum2
    if(nNum1==nNum2)
    begin
        display "THESE ARE EQUAL"
    end
    else
    begin
        display "THESE ARE NOT EQUAL"
    end
end

//WRITE A PSEUDOCODE TO FIND THE SMALLEST OUT OF THREE NUMBERS.

begin
    numeric nNum1, nNum2, nNum3
    display "ENTER THE FIRST NUMBER "
    accept nNum1
    display "ENTER THE SECOND NUMBER "
    accept nNum2
    display "ENTER THE THIRD NUMBER "
    accept nNum3
    if(nNum1<nNum2)
    begin
        if(nNum1<nNum3)
        begin
            display "SMALLEST ONE : " nNum1
        end
        else
        begin
            display "SMALLEST ONE : " nNum3
        end
    end
    else
    if(nNum2<nNum3)
    begin
        display "SMALLEST ONE : " nNum2
    end
    else
    begin
        display "SMALLEST ONE : " nNum3
    end
end

//WRITE A PSEUDOCODE TO CHECK WHETHER THE ENTERED YEAR IS A LEAP YEAR OR NOT.

begin
    numeric nYear
    display "ENTER THE YEAR "
    accept nYear
    if(nYear%4==0)
    begin
        display "THIS IS A LEAP YEAR"
    end
    else
    begin   
        display "THIS IS NOT A LEAP YEAR"
    end
end

//WRITE A PSEUDOCODE TO DISPLAY THE NAMES OF THE DAYS OF A WEEK.

begin
    numeric nCode
    display "ENTER THE DAY CODE : "
    accept nCode
    switch(nCode)
    begin
        case 1 : display "MONDAY"
            break;
        case 2 : display "TUESDAY"
            break;
        case 3 : display "WEDNESDAY"
            break;
        case 4 : display "THURSDAY"
            break;
        case 5 : display "FRIDAY"
            break;
        case 6 : display "SATURDAY"
            break;
        case 7 : display "SUNDAY"
            break;
        default : display "OUT OF RANGE"
    end
end

//WRITE A PSEUDOCODE TO DISPLAY MONTH NAME ACCORDING TO THEIR POSITION.

begin
    numeric nCode
    display "ENTER THE MONTH CODE : "
    accept nCode
    switch(nCode)
    begin   
        case 1 : display "JANUARY"
            break;
        case 2 : display "FEBRUARY"
            break;
        case 3 : display "MARCH"
            break;
        case 4 : display "APRIL"
            break;
        case 5 : display "MAY"
            break;
        case 6 : display "JUNE"
            break;
        case 7 : display "JULY"
            break;
        case 8 : display "AUGUST"
            break;
        case 9 : display "SEPTEMBER"
            break;
        case 10 : display "OCTOBER"
            break;
        case 11 : display "NOVEMBER"
            break;
        case 12 : display "DECEMBER"
            break;
        default : display "OUT OF RANGE"
            break;
        end
end

//WRITE A PSEUDOCODE TO DISPLAY THE STUDENT NAME ACCORDING TO THEIR ROLL NO.

begin
    numeric nRoll
    display "ENTER STUDENT ROLL : "
    accept nRoll
    switch(nRoll)
    begin
        case 1 : display "ANKIT"
            break;
        case 2 : display "RAHUL"
            break;
        case 3 : display "AMIT"
            break;
        case 4 : display "GAURAV"
            break;
        case 5 : display "NITESH"
            break;
        case 6 : display "VISHAL"
            break;
        case 7 : display "CHITRANJAN"
            break;
        case 8 : display "KAUSHAL"
            break;
        case 9 : display "DHIRENDRA"
            break;
        default : display "OUT OF RANGE"
    end
end

//WRITE A PSEUDOCODE TO PRINT THE FIRST FIVE NUMBERS.

begin
    numeric i
    for(i=1; i<=5; i++)
    begin
        display i
    end
end

//WRITE A PSEUDOCODE TO DISPLAY NUMBERS FROM 1 TO 15 USING FOR LOOP.

begin
    numeric nCtr
    for(nCtr=1; nCtr<=15; nCtr++)
    begin
        display nCtr;
    end
end

//WRITE A PSEUDOCODE TO DISPLAY EVEN NUMBERS FROM 1 TO 14.

begin
    numeric nCtr
    for(nCtr=2; nCtr<=14; nCtr=nCtr+2)
    begin
        display nCtr
    end
end

//WRITE A PSEUDOCODE TO DISPLAY UPTO INTEGERS UPTO N.

begin
    numeric nCtr,nNum
    display "ENTER THE VALUE OF N : "
    accept nNum
    for(nCtr=1; nCtr<=nNUm; nNum++)
    begin
        display nCtr
    end
end

//WRITE A PSEUDOCODE TO DISPLAY ALL EVEN NUMBERS UPTO N.

begin
    numeric nNum, nCtr
    display "ENTER THE VALUE OF N : "
    accept nNum
    for(nCtr=2; nCtr<=nNum; nCtr=nCtr+2)
    begin
        display nCtr
    end
end

//WRITE A PSEUDOCODE TO DISPLAY ALL ODD NUMBERS UPTO N.

begin
    numeric nNum, nCtr
    display "ENTER THE VALUE OF N : "
    accept nNum
    for(nCtr=1; nCtr<=nNum; nNum=nNum+2)
    begin
        display nCtr
    end
end

//WRITE A PSEUDOCODE TO FIND THE SUM OF SERIES S=1+2+3+..... +N

begin
    numeric nNum, nCtr
    display "ENTER THE VALUE OF N : "
    accept nNum
    for(nCtr=1; nCtr<=nNum; nNum=nNum+1)
    begin
        nSum=nSum+nCtr
    end
    display nSum
end

//WRITE A PSEUDOCODE TO FIND THE SUM OF SERIES S=1+3+5+.... +N

begin
    numeric nNum, nCtr, nSum
    display "ENTER THE VALUE OF N : "
    accept nNum
    for(nCtr=1; nCtr<=nNum; nCtr=nCtr+2)
    begin   
        nSum=nSum+nCtr
    end
    display "SUM OF SERIES : " nSum
end

//WRITE A PSEUDOCODE TO PRINT THE ALL EVEN BETWEEN 2 AND 100.

begin
    numeric nCtr
    for(nCtr=2; nCtr<=100; nCtr=nCtr+2)
    begin
        display nCtr
    end
end

//WRITE A PSEUDOCODE TO PRINT THE INTERGERS 1 TO N USING while LOOP.

begin
    numeric nCtr=1, nNum
    display "ENTER THE VALUE OF N : "
    accept nNum
    while(nCtr<=nNum)
    begin
        display nCtr
    nCtr++
    end
end

//WRITE A PSEUDOCODE TO PRINT THE ALL EVEN NUMBERS FROM 1 TO N USING while LOOP.

begin
    numeric nNum, nCtr=1
    display "ENTER THE VALUE OF N : "
    accept nNum
    while(nCtr<=nNum)
    begin
        display nCtr
    nCtr=nCtr+2
    end
end

//WRITE A PSEUDOCODE TO PRINT THE ALL ODD NUMBERS FROM 1 TO N USING while LOOP.

begin
    numeric nNum, nCtr=1
    display "ENTER THE VALUE OF N : "
    accept nNum
    while(nCtr<=nNum)
    begin
        display nCtr
    nCtr=nCtr+2
    end
end

//WRITE A PSEUDOCODE TO FIND THE SUM OF SERIES S=1+2+3+.......+N

begin
    numeric nNum, nCtr=1, nSum=0
    display "ENTER THE VALUE OF N : "
    accept nNum
    while(nCtr<=nNum)
    begin
        nSum=nSum+nCtr
    nCtr++
    end
end

//WRITE A PSEUDOCODE TO FIND THE SUM OF SERIES S=1+3+5+......+N

begin
    numeric nNum, nCtr, nSum=0
    display "ENTER THE VALUE OF N : "
    accept nNum
    while(nCtr<=nNum)
    begin
        nSum=nSum+nCtr
    nCtr=nCtr+2
    end
    display "SUM OF SERIES : " nSum
end

//WRITE A PSEUDOCODE TO PRINT THE NUMBERS FROM 1 TO N USING do....while LOOP

begin
    numeric nNum, nCtr=1
    display "ENTER THE VALUE OF N : "
    accept nNum
    do
    begin
        display nCtr
    nCtr++
    end
    while(nCtr<=nNum)
end

//WRITE A PSEUDOCODE TO PRINT ALL EVEN NUMBERS FROM 2 TO N.

begin
    numeric nNum, nCtr=2
    display "ENTER THE VALUE OF N : "
    accept nNum
    do
    begin
        display nCtr
    nCtr=nCtr+2
    end
    while(nCtr<=nNum)
end

//WRITE A PSEUDOCODE TO PRINT ALL ODD NUMBERS FROM 1 TO N.

begin
    numeric nNum, nCtr=1
    display "ENTER THE VALUE OF N : "
    accept nNum
    do
    begin
        display nCtr
    nCtr=nCtr+2
    end
    while(nCtr<=nNum)
end

//WRITE A PSEUDOCODE TO PRINT THE SUM OF SERIES S=1+2+3+....+N

begin
    numeric nNum, nSum=0, nCtr
    display "ENTER THE VALUE OF N : "
    accept nNum
    do
    begin
        nSum=nSum+nCtr
    nCtr=nCtr+1
    end
    while(nCtr<=nNum)
    display nSum
end

thanks
from : dhirendra kumar
dhirendra930@gmail.com
dkonnet.webnode.com