written 2.6 years ago by |
Algorithm:-
An algorithm is a finite set of statements, each of which has a clear meaning and can be executed in a finite amount of time and with a finite amount of effort. Thus whatever is the size of input data, the algorithm can solve the given problem in finite amount of time.
An algorithm is and English language representation of the sequence of steps to be executed to perform a given task. An algorithm can be defined in simple terms as description of the steps necessary to solve a problem. The algorithm should define the procedure to perform the given task. Such algorithms written in simple English language is called as step - form algorithm.
Properties of an algorithm:-
- Non- Ambiguity
- Range of input
- Multiplicity
- Speed
- Finiteness
Write an algorithm to find largest of 3 numbers.
Step 1:- Declare the required variables.
Step 2:- Indicate the user to enter three numbers by displaying suitable sentence using printf() function.
Step 3:- Wait using the scanf() function for the user to enter the input.
Step 4:- Using the proper syntax of the conditional or ternary operator, find the largest of the three numbers and store in another variable.
Step 5:- Display the greatest number using printf() statement.
Step 6:- Wait for the user to press a key using getch() function.
Step 7:- Stop.