Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

5 6260246237891527641

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 61

1-

Start

Enter n numbers

I<=n sum=sum+i

Avg= sum/n

Print

Stop
Algorithm: -

Step 1 -Start

Step 2- Enter n

Step 3- Run loop to n and sum=sum+i

Step 4- Avg=sum/n

Step 5- Print avg

Step 6-Stop
2-

Start

Input A,B

A+A+B B=A-B
A=A-B

Print A,B

Stop
Algorithm: -

STEP 1: START

STEP 2: ENTER A, B

STEP 3: PRINT A, B

STEP 4: A = A + B

STEP 5: B= A - B

STEP 6: A =A - B

STEP 7: PRINT A, B

STEP 8: END
3-

Start

Declare n1,n2,n3 and max

Read n1,n2,n3

Max=(n1>n2)?(n1>n3:n3):(n2>n3?n2:n3);

Print Max

Stop
Algorithm: -

Step 1 -Start

Step 2-Declare a variable a, b, c and largest as integer;

Step 3-Read the number a, b and c;

Step 3-max = a > b ? (a > c ? a : c) : (b > c ? b : c);

Step 4 -print max;

Step 5-Stop
4-

Start

Enter the person’s age

Is age Display “you are


YES
>=18? not eligible to
vote”

NO

Display “you are not


eligible to vote”

Stop
Algorithm: -

Step 1: Start

Step 2: Accept the age of the person.

Step 3: If age is greater than or equal to 18, then


display 'You are eligible to vote'.

Step 4: If age is less than 18, then display 'You


are not eligible to vote'.

Step 5: Stop
Start
5-

Input A,B,C

NO If A>B YES

If B>C NO NO If A>C

YES
YES

Print B Print C Print A

Stop
Algorithm: -

Step 1. Start

Step 2. Input A,B,C

Step 3. If (A>B) and (A>C) then print “A is greater”.

Else if (B>A) and (B>C) then print “B is greater”.

Else print “C is greater”.

Step 4. Stop
6-

Start

Read ch from user

Declare variable ch

Assign
vowels to NO
diff cases

YES

Print “Vowel” Stop


Algorithm: -

Step 1: Start

Step 2: Declare character type variable ch

Step 3: Read ch from User

Step 4: Checking both lower and upper case vowels and assigning
each of them to different case.

IF case matches

Print "Vowel"

Default:

Print "Consonant"

Step 5: Stop
7-

Start

Read number

Switch n FALSE Write odd


%2==0 number

TRUE

Write even
number

Stop
Algorithm: -

Step 1- Start

Step 2-Input number from user. Store it in some variable say num.

Step 3-Switch the even number checking expression i.e. switch(num % 2).

Step 4-The expression (num % 2) can have two possible values 0 and 1. Hence
write two cases case 0 and case 1.

Step 5-For case 0 i.e. the even case print "Even number".

Step 6-For case 1 i.e. the odd case print "Odd number"

Step 7- Stop
8-

Start

Declare variable

Read values and pass


parameters

Add number in function

Print sum

Stop
Algorithm: -

Step 1: Start

Step 2: Declare variable number1, number2 and sum

Step 3: Read Variable number1, number2

Step 4: Perform operation (sum= number1+ number2)

Step 5: Print sum variable

Step 6: Call this function and print value

Step 7: Stop
9-
Algorithm: - Start
Step 1- Start

Step 2-Ask the user to enter three integer values.

Step 3-Read the three integer values in num1, num2, and num3 (integer
variables).
Declare variables
Step 4-Check if num1 is greater than num2.

Step 5-If true, then check if num1 is greater than num3.

If true, then print ‘num1’ as the greatest number.

If false, then print ‘num3’ as the greatest number.


Read values and pass
Step 6-If false, then check if num2 is greater than num3.

If true, thenparameters to function


print ‘num2’ as the greatest number.

If false, then print ‘num3’ as the greatest number.

Compare numbers using function

Print largest

Stop
10-

Start

Read number

I=1 fact=1

Is i<=n NO

YES
Print fact

Fact = fact *1
Stop

I=i+1
Algorithm: -

Step 1: Start

Step 2: Read number n

Step 3: Call factorial(n)

Step 4: Print factorial f

Step 5: Stop

factorial(n)

Step 1: If n==1 then return 1

Step 2: Else

f=n*factorial(n-1)

Step 3:

Return f
Start

Declare A[r][c] B[r][c]


and C[r][c]

Read r,c,p,A[][]
and B[][]

i=0,j=0

yes yes
i<r j<c C[i][j]=A[i][j] + B[i][j]

no
no

i=0,j=0 j=j+1

Print C

End
Algorithm:

Step 1: Start

Step 2: Declare matrix A[r][c];


and matrix B[r][c];
and matrix C[r][c]; r= no. of rows, c= no. of columns

Step 3: Read r, c, A[][] and B[][]

Step 4: Declare variable i=0, j=0

Step 5: Repeat until i < r

5.1: Repeat until j < c

C[i][j]=A[i][j] + B[i][j]

Set j=j+1

5.2: Set i=i+1

Step 6: C is the required matrix after addition

Step 7: Stop
Start

Enter a Number

If Number
%2==0

Yes No

Print Even Print Odd

Stop
Algorithm:

READ number
remainder=number%2
IF remainder==0
WRITE "Even Number"
ELSE
WRITE "Odd Number"
ENDIF
Start

Declare char Str[100] ,int


Length = 0

Read Str

Print length

End
Step 1 -The string is nothing but an array of characters.
Step 2-Read the entered string using gets() function and store into the
character array s[].

Step 3 -The while loop iterates from the first character to the last character
of the array. i.e. the last character of the array is null.

Step 4-Print the i value which is the length of the string.

while
(Str[Length] != '\0')

True
False

Length++
Start

Declare float a[100],


sum=0, avg; int i, n;

Read i,n,a[100]

for(i=0; i< n;
i++)

True
False

sum = sum + a[i]

Print Sum

Print average

End
START

Step 1 → Take an integer set A of n values

Step 2 → Add all values of A together

Step 3 → Divide result of Step 2 by n

Step 4 → Result is mean of A's values

STOP
Start

Declare structure struct student char


firstName[50], int roll,float marks, s[5]

For(i=0;i<5;++i)

False

True

For(i=0;i<5;++i)

Read firstName,roll,marks True False

Print firstName,roll,marks

End
Step 1- Start

Step 2- Declare structure struct


student char firstName[50], int
roll,float marks, s[5]

Step 3- Read firstName,roll,marks

Step 4- Print firstName,roll,marks

Step 5- Stop
Start

Input n1, n2,


n3, n4, n5

Sum=n1 + n2 + n3
+ n4 + n5

Avg=Sum/5

Print Avg

Stop
Algorithm

Step 1- start
Step 2-input the sum.
Step 3- sum( n1+ n2+ n3).
Step 4- AVG sum/3.
Step 5- print avg.
Step 6- stop.
Start

Input a,b

If(a==b)

True
False
Print result

Stop
Algorithm

Step 1- start
Step 2-input numbers
Step 3- check if(a==b)
Step 4- print 1 for true and 0 for false
Step 5- stop.
Start

Initialize variables
like int a, float b

Input from
user a,b

Use sizeof(a)

Display size

End
Algorithm

Step 1- start
Step 2-declare variables with keywords
Step 3- Input value of variables
Step 4- use sizeof function
Step 5- print size of variables
Step 6- stop.
Start

Input n1, n2, n3


Step 1- Start

Step 2- Input n1, n2, n3


True
Step 3- If(n1>n2) Print first no. is
False
largestIf(n2>n3)
If(n1>n2)
Step 4- If(n2>n3) Print second no. is Print second
largest
no. is largest
Step 5- END
True False

Stop
Print first
no. is largest
Start

Declare n1,n2

Input n1, n2

Expression 1

False True

Expression 3 Expression 2

Print expression

Stop
Algorithm

Step 1- start

Step 2-input the numbers

Step 3- variable = Expression1 ? Expression2 : Expression3

Step 4- print or execute expression

Step 5- stop.

You might also like