473,567 Members | 2,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pesudocode to C++

1 New Member
Hi, I need help in converting the pesudocode into c++ code.


Initialize key = ROLLNO, extra = NAME_POSITION
Start the iterator with value 1
If the iteration number is greater than 5, go to step 12
if the ROLLNO is greater or equal to 50
add five to counter
subtract 2 from extra
go to step 6
Otherwise
Double the value of key
Add 3 to extra
Go to step 8
If the ROLLNO is greater than 74
Add 25 to the key
Multiply the extra by 2
Go to step 10
Otherwise
Add ROLLNO to the key
Subtract extra from key
Go to step
If ROLLNO is less than 25
Divide key by 3
Add 4 to extra
Go to step 10
Otherwise
Add 6 to both key and extra
Go to step 10
Add 1 to iterator
Go to step 3
Output key, extra
Stop
Jan 3 '23 #1
2 4045
dev7060
639 Recognized Expert Contributor
Hi, I need help in converting the pesudocode into c++ code.


Initialize key = ROLLNO, extra = NAME_POSITION
Start the iterator with value 1
If the iteration number is greater than 5, go to step 12
if the ROLLNO is greater or equal to 50
add five to counter
subtract 2 from extra
go to step 6
Otherwise
Double the value of key
Add 3 to extra
Go to step 8
If the ROLLNO is greater than 74
Add 25 to the key
Multiply the extra by 2
Go to step 10
Otherwise
Add ROLLNO to the key
Subtract extra from key
Go to step
If ROLLNO is less than 25
Divide key by 3
Add 4 to extra
Go to step 10
Otherwise
Add 6 to both key and extra
Go to step 10
Add 1 to iterator
Go to step 3
Output key, extra
Stop
What have you done so far?
Jan 4 '23 #2
BloomS
8 New Member
Expand|Select|Wrap|Line Numbers
  1. // C++ Code
  2.  
  3. int key = ROLLNO;
  4. int extra = NAME_POSITION;
  5.  
  6. for (int i = 1; i <= 5; i++) {
  7.     if (ROLLNO >= 50) {
  8.         key += 5;
  9.         extra -=2;
  10.     } else {
  11.         key *= 2;
  12.         extra += 3;
  13.  
  14.         if (ROLLNO > 74) {
  15.             key += 25;
  16.             extra *= 2;
  17.         } else {
  18.             key += ROLLNO;
  19.             key -= extra;
  20.  
  21.             if (ROLLNO < 25) {
  22.                 key /= 3;
  23.                 extra += 4;
  24.             } else {
  25.                 key += 6;
  26.                 extra += 6;
  27.             }
  28.         }
  29.     }
  30. }
  31.  
  32. cout << key << " " << extra << endl;
Jan 4 '23 #3

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

Similar topics

7
1390
by: pythonnoob | last post by:
Im new to programming, expecially c++. I started off in python but really just know the basics. My question is, how would i go about writing a program that would output all of the numbers (whole numbers) on a plane between X and Y, saw 0,0 and 10,10? I can get my code to write the basics from 0-10 with a while loop, but only for 1 axis. ...
2
2214
by: Ronald Raygun | last post by:
I have a form that I am using as a wizard. The wizard comprises of several forms contained in divs, which are hidden/made visible, depending on the wizard step. Each form has an action parameter set to a different php script, which is responsible for returning a true/false (+ mesage back to the form. So I have something like this: <div...
0
7590
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8115
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7960
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6272
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5488
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5216
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3648
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
930
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.