Ask Experts » Computers » Software »

How to develop the C program using pseudo code.


Date: 06 Apr 2009    Group: Computers    Category: Software   

If there is a pseudo code, using that how to develop the program. Kindly give me one example for developing the C program using pseudo code.



Author: upasana    25 Apr 2009      Member Level: Silver     Points : 2  (Rs 2)    Voting Score: 0

Psuedocode is basically a mnemonics language. the c program is quite different from it. i am assuming that you know c basics. firstly take the initialization part. include data types in it as : data_type variable. a psuedocode for it may be like: initialize i to zero etc. Next comes the condition part. It may read as: If i is equal to zero then this else this or a for loop may come etc. During this part take care that you use proper indentation. next comes the output part. in pseudocode it may come as display or print. these signify a need of output statement like printf , puts etc. for input statements scanf or gets may be used. do include proper header files and comments in the progarm.

Author: Pratik Pansare    29 Apr 2009      Member Level: Gold     Points : 4  (Rs 2)    Voting Score: 0

Pseudocode (or false code) can be said to be a language independent code. It means that once you are given a pseudo code you can convert it to any language code like C, java, VB and many more. C programs (or other languages programs like java or VB) basically can be related to a human language like English. Like English sentences are constructed from words, which are made from alphabets C follows a similar approach. here keywords, constants, variables, identifiers are used to create lines of code. These are the constructs of the C language.

In order to develop a program (from pseudo code or otherwise) you will need the following ingredients.
1. Language constructs (given in above para).
2. decision statements (yes/no)
(decisions in C a taken using 'if...else' and 'switch' keywords)
3. looping statements (to execute a particular action repeatedly)
(this is done using 'for', 'while' and 'do..while' keywords)

Now firstly see the pseudo code to understand the logic that your program will need to implement OR understand the task at hand.
Next you the 3 broad type of ingredients given above and simply replace abstract concepts used in Pseudocode that you have, with the C language constructs (ie ingredients), to create the program that you want to make / implement.


Author: Deepak Chand babu R S    08 May 2009      Member Level: Gold     Points : 2    Voting Score: 0

Hi,

Pseudo code can be seen as a program without appropriate language constructs. We have to understand the flow of the program. Then we have to identify the language constructs. Then with the help of the syntax identified, we have to build the code. If the syntax or the language constructs are based on the C Language,then we could end up with an appropriate C program.

Regards,
Deepak.


Author: Narmada Chowdary    14 May 2009      Member Level: Silver     Points : 3  (Rs 3)    Voting Score: 0

Pseudo code is an artificial and informal language.It is the text based tool to write the algorithms.The algorithms of programs are mentioned in simple english.

One needs to understand the pseudo code properly.Follow the steps.

1)Read the code twice or thrice.

2)Try to understand the input and outcome of the code.That is what is to be given at the start(sometimes they will be no input) and what is the final result one can get through that code.

3)Once you understood the input and output of the code.Then move to study the code and understand,what is done to get the output.That is get the logic.

4)Now,once you understand the logic,simply apply the valid terms of the language into which you want to convert it.

For example:

if total is greater than 60
print pass
else
print fail

So, once you study this code-You have to give an input to the total variable and the output should be a print statement.The print statement depends on the decision statement IF which is done through comparison

Program:
main()
{
int total;
printf("Enter the value of total: ");
scanf("%d",&total);
if(total>60)
{
printf("Pass");
}
else
{
printf("Fail");
}
getch();
}

So,in this way you can convert a pseudo code to a c program



Author: Nipesh Shah    17 May 2009      Member Level: Gold     Points : 1    Voting Score: 0

Pseudo code is a method of performing some task describe in a English language with some programmatic words.

To convert it to the program. First we need to understand the
process of that.
What exactly the code does.
After then we can easily convert it into the program.


Author: Shashikant Gupta    22 May 2009      Member Level: Gold     Points : 2    Voting Score: 0

A pseudo code, as its name suggests is just a false code, that intends to explain the functionality or execution sequence of the Program. It is generally written using programming constructs like IF, WHILE, UNTIL etc... Its not actually the code but a set of normal statements explaining the execution of the program. It is written before developing the actual program. It is like developing the skeleton of the program before actually starting programming.

There can be ways to design programs automatically from its pseudo code given that there's always a fixed format for writing pseudo codes. Since pseudo codes does not have any particular syntax for writing, they cannot be interpreted to develop a corresponding code for it automatically.

Pseudo codes makes easier for a non - technical person to understand what the program does, rather than looking through all that technical code.

So you need to understand every step of pseudo code and convert it into corresponding code in whatever programming language you are using.

For example, Following is the pseudo code for finding whether a given number is even or odd.

1) Input number 'X' from user
2) Divide the X by 2 and store its remainder As 'R'
3) if R is 0 then print 'X' is an even number
4) if R is not 0 then print 'X' is an odd number.
5) Exit

Now you can understand from the above program that if a given number is divisible by 2 then it is an even number else it is an odd number . (please note that even 0 i.e. zero is considered an even number. Check this at http://en.wikipedia.org/wiki/Parity_(mathematics) )

So you can translate above pseudo code steps into a proper code as below :

C Program to find out whether a given number is even or odd.

Program:

#include
#include
void main()
{
int x,r;
x = 0;
r = 0;
clrscr();
printf("Enter a number ");
scanf("%d", x);

r = x/2

if (r = 0)
printf("Given number is Even")
else
printf("Given number is Odd.")


getch();
}

I hope you now got an idea how to develop the C program using pseudo code.



Author: pinkysinha    07 Jun 2009      Member Level: Silver     Points : 2  (Rs 2)    Voting Score: 0

HI FRIEND
YOU read these lines carefully
Pseudo code is an artificial and informal language.It is the text based tool to write the algorithms.The algorithms of programs are mentioned in simple english.

One needs to understand the pseudo code properly.Follow the steps.

1)Read the code twice or thrice.

2)Try to understand the input and outcome of the code.That is what is to be given at the start(sometimes they will be no input) and what is the final result one can get through that code.

3)Once you understood the input and output of the code.Then move to study the code and understand,what is done to get the output.That is get the logic.

4)Now,once you understand the logic,simply apply the valid terms of the language into which you want to convert it.

For example:

if total is greater than 70
print pass
else
print fail

So, once you study this code-You have to give an input to the total variable and the output should be a print statement.The print statement depends on the decision statement IF which is done through comparison
Program:
main()
{
int total;
printf("Enter the value of total: ");
scanf("%d",&total);
if(total>70)
{
printf("Pass");
}
else
{
printf("Fail");
}
getch();
}

So,in this way you can convert a pseudo code to a c program
and by this you can develop c programming


Author: N V V K Raju    25 Jun 2009      Member Level: Silver     Points : 0    Voting Score: 0

Using pseudo-code to design application logic

Pseudo-code is a non-formal language, a way to create a logical structure, describing the actions, which will be executed by the application. Using pseudo-code, the developer describes the application logic using his native language, without applying the structural rules of a specific programming language. The big plus of the pseudo-code is that the application logic can be easily understood by any developer in the development team (in this case, it doesn’t depend, which programming language knows each team member). Also, when the application algorithm is described in pseudo-code, it is very easy to transform the pseudo-code into real code (using any programming language). For a better understanding of what is pseudo-code, let’s take a look at an example. Suppose that you have to develop an application, that gets the number of students in a high school and then it gets each student’s final grade (100, 90, 80, 60 and 50) and processes the average grade for the whole school. Instead of creating the program at a computer, let’s describe the application logic using pseudo-code. First, I will describe the general purpose of the application:

Code:

Process the average grade for the whole school;

Now, I need to specify the fundamental actions that are needed to process the final result:

Request the number of students;
Get the grade for each student;
Process the average grade for the whole school;




This is a generalized description, but it describes the basic application logic. Now, I have to specify some more details (how the above actions are performed):




Application start;
Declare an integer variable numberOfStudents;
Declare an integer variable counter;
Declare an integer variable sum;
Declare a decimal variable average;

Set the numberOfStudents value to 0;
Set the counter value to 0;
Set the sum value to 0;

Request the number of students (numberOfStudents);

If the entered number of students is 0 then
Exit the application
Else
While the counter is less or equal to the number of students
Get the student grade
Add the student grade to the sum variable
Increment the counter by 1.
Get the next student information

When the student information is entered, set the average variable to the result of the division (sum divided by the number of students).
Show the result.
Application end.


Author: peeyush jain    30 Jun 2009      Member Level: Silver     Points : 1    Voting Score: 0

hi frd,
i think already its explained; but i suggest to read this book
will help you.

Foundations of Algorithms Using C++ Pseudocode, Third Edition (Hardcover)
by Richard Neapolitan (Author)



Author: Sunil Saharan    03 Jul 2009      Member Level: Gold     Points : 4  (Rs 3)    Voting Score: 0

Dear Friend,
pseudo code is one among the famouse methods to implement C programmes. As psedu code is an algorithm making procedure, so it may help you a lot while you are learning the basics of C language. These are also helpful for professional programmers also.
Before writing a C program you should follow the following steps :-
1. Read the problem carefully.
2. Develope the procedure to solve in your mind.
3. Write psuedo code.
4. Write the C program.
The important advantage of using psuedo code is that you can you them while writing program in any other language as these codes are universal.
It is assumed that you know the basics of data variable declaration and you may use functions.
For more information you may visit :-
HERE
Thanks for your time.
SUNIL SAHARAN





Post Answer



You must Sign In to post a response.


Post Answer        





Related Questions
  • Return to Question Index
  • Ask Question to Experts

  • Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.