C# :: Writing Pseudo Code - Program That Converts Or Reverses Input String

Feb 20, 2014

I have made a program that converts or reverses an input string. Here is my code working fine

static void Main(string[] args){
string input = Console.ReadLine();
string[] words = input.Split(' ')
for (int i = words.Length; i > 0; i--)
Console.Write(words[i - 1] + " ");
Console.WriteLine();
Console.ReadLine();
}

How can I write this program in pseudo code?

View 2 Replies


ADVERTISEMENT

C++ :: Writing Pseudo Code And Flow Charts

Apr 15, 2013

I have finished writing the code for the following program. I have concerns with the pseudo-code that I have written and the flow chart seems really complicated. I dont know how to build it. Here is the question:

An Internet service provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access is provided.

Write a program that calculates a customer s monthly bill. It should ask which package the customer has purchased and how many hours were used. It should then display the total amount due.

Input Validation: Be sure the user only selects package A, B, or C. Also, the number of hours used in a month cannot exceed 744

Here is my program:
#include <iostream>
using namespace std;
int main() {
char package;
int hours;

[code]....

What should be my pseudocode and flowchart ? Can i copy and paste my pseudocode here ?

View 2 Replies View Related

C++ :: Convert Pseudo Code Into Program For Searching Value Of Array

Jun 29, 2014

What is the program of this pseudo code?

Set found to false.
Set position to -1.
Set index to 0.
While found is false and index < number of elements
If list[index] is equal to search value
found = true.
position = index.
End If
Add 1 to index.
End While.
Return position

View 5 Replies View Related

C++ :: How To Make A Program That Converts Input Numbers Into Equivalent Words

Nov 16, 2013

I've reached a point in "Jumping into C++" where I need to make a program that converts input numbers into their word equivalent.

So far I've made it work for numbers 0-9999. I've tried implementing 10000-99999 but there are problems with the order of the words printed (57865 would print fifty thousand seven thousand eight hundred sixty five). But besides that, the program is absolutely enormous (for me) and I'm wondering if it can be shortened. Keep in mind I can only use loops and if statements so far. Here it is:

Code:

#include <iostream>
#include <string>
void extras(int e);
void digits(int x);
void tens(int xx);
void hundreds(int xxx);
void thousands(int xxxx);
//void tens_of_thousands(long xxxxx);

[Code]....

View 6 Replies View Related

C :: Print Out - Array Code And Pseudo Code?

Apr 15, 2013

I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.

View 2 Replies View Related

C :: Reading Pseudo Code For Car Robot?

Sep 12, 2014

I'm doing a practice problem where I need to read pseudo code and understand what it does.

For this code, I believe it will move the robot forward while i<650, so it moves it forward for 650 steps in total. Then it sets the motors to 0 when it's finished.

Code:
while(i<650)
{ rotateCW(2);
rotateCCW(1);
Delay1KTCYx(50);
i++;
LATD=0x00; //Set all Port D to 0
}

This code I'm having the most trouble with. So while(1) the pot(potentiometer) read's the ADC. Then it scales the adc, not 100% sure what the +20 and *.22 mean, I think it has to do with binary conversions?

Now it sets pin 1 of port 1 to 0, delays based on pot above, and sets it back to 1, and delays again. I assume something to do with controlling motor speed based on the potentiometer.

Code:
void main(void){TRISD = 0x00; // Setting port D to outputs
LATDbits.LATD0 = 1; // Setting bit 0 of port D to 1
while(1) {
pot = readADC();
pot = pot * 0.2297 + 20;

[Code] ......

My best guess is: The car moves forward 400 steps, stop, turn right for 230 steps, stop. At this point it would begin moving straight, and it would turn left/right as needed to keep the robot in the center of the track.

Code:
void main(void) {
for(i=0;i<400;i++) {
rotateCW(2,motor); //Rotate motor two (one step)
rotateCCW(1,motor); //Rotate motor one (one step)
Delay1KTCYx(50);

[Code].....

View 5 Replies View Related

C/C++ :: Pseudo Code Implementation Using Three Semaphores

Apr 27, 2014

Write a program to implement the following Pseudo Code using three semaphores.

Here is the pseudo code:

int sizeofbuffer = 10
semaphore Access = 1, Item = 0, EmptySpace = sizeofbuffer;
int nNumberOfItem = 0;
void Farmer() {
while ( true ){
semWait( EmptySpace );

[Code] .....

View 3 Replies View Related

C++ :: Create A Top Trumps Game Using Pseudo Code?

Jan 3, 2015

I want to create a top trumps game using pseudo code with variables, loops, If statements and inputs, how would I write it?

View 3 Replies View Related

C :: Design Algorithm Using Flowchart Or Pseudo Code To Prompt User For Series Of Positive Integer Value

Oct 26, 2014

Design an algorithm using flowchart or pseudo-code to prompt the user for a series of positive integer values. Calculate the average of these values and display the average at the end of the program. Assume that the user types the sentinel value -1 to indicate end of data entry.

Sample input-output:
Enter a positive integer (-1 to end) : 5
Enter a positive integer (-1 to end) : 7
Enter a positive integer (-1 to end) : 6
Enter a positive integer (-1 to end) : -1

The average value is: 6

I searched online and found out this solution however it is only for three numbers.Is there any way of modifying this to include the sum of x numbers / number of x(integers) to find the average?

View 5 Replies View Related

C :: Command Line And Converts String From File Into A Linked List

Jul 10, 2013

My program takes in an input file from the command line and converts the string from the file into a linked list and then depending on the command it will manipulate the string to either reverse the list, print the list, or take a character out...I'm having trouble taking a character out, my code compiles fine but doesn't change the string at all

Code:

#include <stdio.h>
#include <stdlib.h>
#define SIZE 1024

[Code]....

View 4 Replies View Related

C++ :: Writing Program That Asks User To Input Number?

Sep 11, 2013

im writing a program that asks the user to input a number 1-10 and will transform it into the roman numeral of that number but it seems that its not after the user inouts the number nothing will output

#include <iostream>
#include<iomanip>
using namespace std;

[Code]....

View 3 Replies View Related

C :: Program That Converts Decimal To Any Base (mostly)

Jan 30, 2013

I had the idea to write a program that would convert a decimal integer into any base up to 36 (there are no letters after that) so I decided to give it a try.

Code:
#include <stdio.h>
#include <stdlib.h>
char letters(int r); // prototypes function for converting 10's to A's and so on, base 11+ will work
int main() {

int base;
int d; //declares decimal integer
int d_clone; // clones d for a loop

[Code] ......

View 8 Replies View Related

C/C++ :: Get Code To Sum A String Of Numbers Input From A File

Nov 5, 2014

This program gets input from a file and output to the screen and to a file. The difficulty I am having is summing the number I retrieve from the file for the individual numbers of sightings.

#include <fstream> // enables us to read and write files
#include <iostream> // for cin and cout
#include <cstdlib>
#include <string> // enables us to hold strings of characters
#include <cctype>
using namespace std;

[code].....

View 14 Replies View Related

C :: Write A Program That Converts Alphanumeric Phone Number Into Numeric Form

Mar 6, 2015

i m learning c programming and i m stuck with this program for some reason.Write a program that converts alphanumeric phone number into numeric form:

O/P:
Enter phone number: CALLAT 2255288
here is the code i have written:
/** compilers shows no error **/
and O/P I get is
Enter phone number: CALLAT
/**blank space***/

Code:

#include<stdio.h>
int main(void)
{
char ch;
printf("Enter phone number:");
ch=getchar();
}

[code]....

View 4 Replies View Related

C :: Function Which Takes A Character Array And Reverses It

Dec 7, 2013

Write a c function which takes a string(as a character array, null terminated) and reverses it. it doesn't print the reversed string -- it modifies the given string so that it is reversed.

Code:

void reverse(char array[]) {
char tmp;
int i, j;
for(i=0;i<strlen(array); i++){
for(j=strlen(array)-1;j>=0;j--) {
tmp = array[i];
array[i] = array[j];
array[j] = tmp;
} } }

how come this doesn't work?

View 2 Replies View Related

C/C++ :: Writing A Code For Bitmap File Format

Mar 9, 2014

I wanna write a piece of code in C++ that extract the width and height of a image with bmp file format...

View 2 Replies View Related

C++ :: Program That Will Allow A User To Input Their First Name Into A String

Feb 23, 2015

So we have a weekend assignment that is "Write a c++ program that will allow a user to input their first name into a string, and use the switch/case statement to produce the following output. Your Program should prompt the use rwith the numbers and the options for each (school, classification, and mood) allowing them to make a choice"

My issue is with the output. The output at the end is the number that they input and not the name of the case they chose, so if they chose option 1 for school it does not print out "BRCC" at the end for the output it prints a 1.

#include <iostream>
#include <string>
using namespace std;
int main(void) {
string name;
cout << "Please enter your name: ";
cin >> name;

[code].....

View 7 Replies View Related

C++ :: Program To Reverse Input String

Nov 3, 2014

Explain this program to reverse an input string:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main() {
void reverse(void);
clrscr();
reverse();

[Code] ....

Do not assume i know about getchar and putchar.

View 2 Replies View Related

C++ :: File Writing - Input Your Login Info And Program Writes That Info To A Text File

Jan 30, 2013

I'm trying to make a program that you input your login info and it writes that info to a text file. Then, later on once I get my problem fixed, the program will read the info to the user. my code is as follows(the input part is a bit lengthy):

// Password Log
#include <iostream.h>
#include <fstream.h>
#include <string>
#include <time.h>
using namespace std;
ofstream login;

[Code] ....

What my problem is when I choose "Input new login info" it automatically inputs I have no clue, and calls next program.

View 3 Replies View Related

C++ :: String Compare Program - How To Put Input In Quotes

Nov 30, 2013

I am working on a String compare program and i got the program to work properly i was just wondering how to put user input into quotes.

here is my programming

int main {
const int LENGTH = 40;
char s1[LENGTH], s2[LENGTH];
cout << "== String Compare ==" << endl;
cout << "Enter a word" << endl;

[Code] ....

the input is :
Dorito
dorito

the output needs to look like this:

"Dorito" comes before "dorito".

View 2 Replies View Related

C :: Program That Allow User To Input String Then Scans The File

Sep 21, 2014

This program will allow the user to input string then scans the file if it contains the same string given by the user. But i always get "MATCHED" even if i enter random string. I tried and tried to place the if statement in different positions but i dont get my expected output.

Code:
#include<stdio.h>#include<stdlib.h>
#include<time.h>
#include<string.h>
int main() {
int found;

[Code] ....

View 6 Replies View Related

C :: Bulls And Cows Program - Compare Table With Input String

Dec 14, 2013

I'm having a small problem on comparing a table i coded with a string that I want to input. I'm actually building a Bulls and Cows program and this is part of my assignment. What i want to do is to input a string and from the table get the results compared to the string i inputted.

Few words about the Bulls and Cows program.

The game involves two players, a coder and a cracker. The coder (either a person or a computer) chooses the four-digit number with all different digits and keeps it secret. The cracker tries to guess the secret number. After a guess, the coder gives you information about number of digits which were correctly guessed but in the wrong place (they are called 'cows') and how many are both the right digit and in the correct place (they are called 'bulls').

For example, if the coder chooses the secret number 0419 and the cracker guesses 6039, then the coder scores this as 1 cow, since 0 is a digit in the secret number that's in the wrong place, and 1 bull (9 is in the right place.)

what i want to do is when i input a string it scans the whole table of possibilities and gives me the results based on the string. so each row of my table is (let's say the secret code) and based on the given string(the guess) it gives me the result. Here's my table code:

Code:
void initialize(int poss[1296][4])
{
int i=0;
int j, k=0;
int m;

[Code] .....

View 2 Replies View Related

C++ :: Write Program That Uses Boost Library To Input String Date?

Apr 23, 2014

I'm trying to write a program that uses the Boost library to input a string date in the format mm/dd/year and outputs to the string its corresponding day of the week. I wrote the program that I thought would accomplish this, but it doesn't seem to work. Below is the code I wrote:

#include <string>
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"

[Code]....

When I compile this using codeblocks it gives me the error "In function `ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtRKSs':|
C:Users
osaDesktop est3........Liboost_1_55_0oostdate_timedate_parsing.hpp|67|undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()'". And it takes me to the file date_parsing.hpp and highlights line 67. I don't understand why this isn't working.

View 3 Replies View Related

C++ :: Logic - Writing Input To TXT File

Oct 30, 2014

So I'm trying to take some information that a user inputs and to then write it into a .txt file. The user would input a student ID followed by 4 quiz grades. I need to use nested loops for the input, a while loop for the outer and a for loop for the inner.

The data in the .txt should would look like:
studentID quiz1 quiz2 quiz3 quiz4
studentID quiz1 quiz2 quiz3 quiz4
etc.

My problem is I'm not sure how to structure the code. I have very few examples I'm working with to understand what I'm working with.

View 2 Replies View Related

C/C++ :: Writing And Reading From Standard Input

Mar 18, 2015

I have an HTTP/1.0 webserver that I'm building in C that needs to exhibit CGI script functionality. Specifically, what I'm having trouble with is that I have two processes: process 1 is the webserver, process 2 is the CGI script. I fork in the webserver, and then call exec to run the CGI script (specifically, I used execv()). I've read from the CGI specifications in the RFC that in the case of a webserver receiving a POST request, the CGI script should read the arguments for the POST request from stdin. However, when I write to stdin, it simply echoes what was written to the terminal window and when the CGI script tries to read from stdin, it blocks.

So, with all that said, I'm pretty sure there is some simple conceptual explanation to my problem, but I can't figure it out. Do I need to use pipes or some form of interprocess communication to send the data from the webserver to the CGI script, or can it just be done with stdin (and possible stdout)?

View 2 Replies View Related

C++ :: Function Index That Converts Int From 0 To 5 Into Its Word

Apr 9, 2013

Task: - Write a function `index` that converts an int from 0 to 5 into its word. (It should take an int and return a string.)

0 -> "zero"
1 -> "one"
2 -> "two"
3 -> "three"
4 -> "four"
5 -> "five"
anything else -> "other"

#include <iostream>
using namespace std;
string index(int x) {
if(x=0)
return "zero ";
else if(x==1)

[Code] .....

It compiles but doesn't print anything.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved