Pseudocodes are a means to represent an algorithm in a coded
form.The specifications used in a pseudocode are syntactically not stringent as
in a program code. However, they represent the steps of an algorithm in a coded
from which very closely resembles program code. Given a pseudocode,translation
of the same into program code is relatively easy. A pseudocode may be
considered to be an intermediate code between an algorithm and program code.
The pseudocode for the algorithm in below example:-
Pseudocode SUMN
{
print "Enter a value for the number N: "
scan N
I=1
SUM = 0
while I <= N
{
SUM = SUM+I
I=I+1
}
print "The sum is: ",SUM
}
It should be noted that a pseudocode is slightly more cryptic compared to
an algorithm and is closer in form to a C program code. The C code for the
pseudocode shown here would be as follows :-
#include<stdio.h>
Main()
{
Int I,SUM,N;
Printf(“\n Enter a value for the number N:”);
Scanf(“%d”, &N);
While(I <= N)
{
Sum=Sum+I;
I=I+1;
}
Printf(“\ The sum is: %d” , SUM);
}
No comments:
Post a Comment