473,479 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

convert pseudocode into C code

2 New Member
hi... can anyone tell me how to convert the below pseudocode segment to a C program

Expand|Select|Wrap|Line Numbers
  1. while true
  2.           do repeat j--
  3.                  until A[j] <= x
  4.              repeat i++
  5.                  until A[i] >= x
  6.  
this is from quicksort partition algo. also pls tell me how to write true and repeat until in C
thnxx
Sep 2 '10 #1
5 12078
code green
1,726 Recognized Expert Top Contributor
It seems odd that you are asking us to write a piece of code for you when you have the algorithm.

Your questions suggest you don't know C at all, so if learning why start with something so tricky?
Sep 2 '10 #2
Nepomuk
3,112 Recognized Expert Specialist
Hi!
This code is very c-like, so you don't have to change much. What you'll be using is called "loops" and there's a tutorial here, that should point you in the right direction. One tip from me: You're going to need 2 of the 3 types of loops that you'll find in that article.

Oh, and in C you don't have predefined values true and false, but you can either define them yourself by putting the following code in the head of your program:
Expand|Select|Wrap|Line Numbers
  1. #define TRUE   (1)
  2. #define FALSE  (0)
or you can just use 1 as true and 0 as false or you can use
Expand|Select|Wrap|Line Numbers
  1. #include <stdbool.h>
to define the datatype bool which can have the values true and false... Or I'm sure there are other ways to do it too.

Greetings,
Nepomuk
Sep 2 '10 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. #define TRUE   (1) 
  2. #define FALSE  (0) 
You might want to #define TRUE as !FALSE. All values are TRUE that are not FALSE.
Sep 2 '10 #4
donbock
2,426 Recognized Expert Top Contributor
You might want to remove the definition for TRUE. I suggest that you only work with the FALSE macro.
Expand|Select|Wrap|Line Numbers
  1. for(done=FALSE; !done; )
  2.    done = doSomething();
  3.  
  4. int doSomething(void) {
  5.    return !FALSE;
  6.    }
Whatever value you may choose for your TRUE macro, there will be many values that differ from TRUE, but that are still logically true.

However, if you're using C99 then you should include stdbool.h and use the facilities it provides.
Sep 2 '10 #5
haarsh
2 New Member
thnxx guys...:D
Sep 3 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

26
13508
by: sam | last post by:
Hi, Can anyone help me find a software that can convert a code in 'C' to 'Fortran77/90' automatically? Thanks in advance. Sam.
1
1385
by: New Devil | last post by:
Hi all, Can anybody help me to convert this code from VB to C#....i got this code from msdn but i want to do this in C# .... plz help if u can....thanx the code is......
2
3639
by: Striped | last post by:
Is there any tool to convert source code, e.g. of a C# method, to opcodes being used in System.Reflection.Emit? It's a real pain to do that manually, especially for big pieces of code. public...
3
12594
by: Ian | last post by:
I need to convert the code in http://support.microsoft.com/?kbid=240653 to VB.net Does anybody know what should be done? Thanks. Ian
2
16079
by: sindhu80 | last post by:
Hi, Can somebody help me to convert the following code to c# function uploadToImageshack($filename) { $ch = curl_init("http://www.imageshack.us/index.php"); ...
1
1731
by: creatigent | last post by:
How to convert this code to C#, Thanks char ID; ID='\0'; srand((long) time(NULL)); char Result;
1
1910
by: omy2k | last post by:
I have been trying to convert this code to visual C#. can nyone help? #include <stdio.h> #include <time.h> clock_t start = clock(); /* Code you want timed here */ printf("Time elapsed: %f\n",...
1
2786
by: krishnaneeraja | last post by:
Hi, im developing a web application.In that i want search engine code.but i have that code in PHP.so plz help me how to convert PHP code to C# code. Giv me any reply. Thanks & Regards,...
9
4966
by: aliusman | last post by:
Hi Every one, I have a perl script which uses the following code to decode the username saved in a cookie. I want to parse that cookie in php for adding some more features in the application. The...
5
1550
Eleven
by: Eleven | last post by:
Hi, Can someone please help me convert this code snippet from VB to C# <% If Session("PartnerLoggedIn") Then %>Partner User logged in: <b><%=Session("PartnerUserName")%></b> - on behalf of - <%...
0
7027
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.