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


ADVERTISEMENT

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 :: 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++ :: 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# :: 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 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++ :: Turbo Code To Print String Through Installed Printer

Nov 10, 2013

C++ Code To Print String through Installed Printer. How to user Printer File Name?

View 9 Replies View Related

C++ :: Read HTML Code - Count / Sort And Print Out Only First 10 Frequently Used Attributes

Mar 14, 2013

I have to write a c++ program to read html code and do bunch of stuff. One thing that i have to do is to count the no of attributes and sort them in descenting out and print out only first 10 frequently used attributes. I counted them using maps and sorted them using multimaps but now dnt knw how to print only 10 elements

for(std::map<string, int>::iterator it = Element.begin(); it != Element.end(); ++it)
Elements.insert(pair<int, string>(it->second, it->first));
for(std::multimap<int, string>::reverse_iterator it = Elements.rbegin(); it != Elements.rend(); ++it) {
cout << "Element: " << it->second << " : " << it->first << endl;
}

This is how i did it . How to display only 10 elements and not all the elements.

View 17 Replies View Related

C++ :: Reducing Code Duplication From Common Code Calling Common Class

Apr 13, 2014

I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.

However, Is designing a complete class just for a few functions over kill?

Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?

View 4 Replies View Related

C++ :: Code To Read 2D Array From TXT File

Apr 11, 2013

So the premise of my code is to read in a 2d array from a .txt. The array is a game board but the first two lines are what determine the size of the board. After i read it in i want it to find wherever te character "U" is, and then display the array but only showing U and whats around it. Problem is i cant get the array to print the right size and the code for displaying the U is not working either.

ifstream inputFile;
int boardSizeRow;
int boardSizeCol;
inputFile.open("C:UsersMichaelDesktopfileboard2.txt");
inputFile >> boardSizeRow;
inputFile >> boardSizeCol;
inputFile.get();

[Code]...

FILE:

20
20
WWWWWWWWWWWWWWWWWWWW
W GO W W
W WW w S W
W H W GW w W
WPW WW G W
WK W W
W W W W w w W
WK WU W
SW w w W
W W
w W G W
G W w W
D wwwww W
K w D W
w w W w w W
ww w WWWWWWW
G w W
ww w S w W
WWW G W
WWWWWWWWWWWWWWWWWWWW

View 5 Replies View Related

C/C++ :: Converting 2D Array Code To Malloc

Mar 2, 2015

I made a program that adds two matrices and displays their sum with a max dimension of 100.

/* This program asks the user for 2 matrices called A and B, as integers,
and displays their sum, C. The max dimension of each matrix is 100. */

#include <stdio.h>
// Construct function
void construct() {
int m, n, i, j; // Variables
int first[100][100], second[100][100], sum[100][100]; // Matrices variables

[Code] ....

Now I need to change it so there is no max size for each matrix. The arrays will be larger than 100x100 so I need to use malloc to create my arrays. So I cant use int A[rows][cols]. This is what I did to covert arrays to malloc. It compiles but it crashes after I entered all the integers.

/* This program asks the user for 2 matrices called A and B, as integers,
and displays their sum, C. The max dimension of each matrix is 100. */

#include <stdio.h>
#include <stdlib.h>
// Construct function
void construct() {
int m, n, i, j; // Variables
int *first = NULL;

[Code] .....

View 8 Replies View Related

C++ :: Defining Struct In Code Using Array Class

Mar 16, 2013

Is it any different when using a class in my code. My previous code i define my struct like this

Code: #include <iostream>
#include <fstream>
#include <string>

struct{

[Code] .....

or do i still define it the same way at the top of my code.

View 4 Replies View Related

C++ :: Code That Returns Maximum Sum Of A Subsequence From A Array

Aug 25, 2014

Here's the code that returns maximum sum of a subsequence from a given array. This is according to "Programming Pearls" by Jon Bentley. I have come up with an example for which this program won't work. And here's that example:

{ -10, 11, 10, -10, 2, 3, -6, 1 }

Max subsequence sum above is 21. 2nd and 3rd elements.

But the program returns 16. It sums 2nd through 6th elements and returns. Why would the writer explain something with such depth, only to give a program that doesn't work in all instances?

int MaxSum(int lo, int hi, int* arr) {
if (lo > hi) {
return 0;
}
if (lo == hi)

[Code]...

View 11 Replies View Related

C/C++ :: How To Get Array Of Structure Code To Read Form A File

Dec 10, 2014

I tried to make the program read from a file text the first name or last name but o cant seem to get it. i tried alot of different ways. how can i get the array of structure code to read form a file?

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
const int NUM_STUDENTS = 17;
const int NUM_QUIZZES = 10;
const int NUM_EXAMS = 5;

[Code] .....

View 14 Replies View Related

C++ :: Translate Char Array From (Russian Code) To Unicode?

Feb 10, 2012

How translate char array from "MS-DOS Codepage 866" (Russian code) to Unicode?

View 3 Replies View Related

C++ :: How To Add A Loop / User-defined Function And Array / Structure To Code

Apr 24, 2012

We had to write a "selling program for computers, laptops and tablets", which I did but for the extra credit, we have to have those three points in the application and I have tried but how to do the "extra credit" part, which I really need.

1.) A loop to prompt the user if they would like to place another order

2.) At least one user-defined function

3.) An enumerated data type, array or struct (structure)

I did one of these three, it's a "DO WHILE" loop asking users if they want to make another order, it's right at the beginning of the code.

Code:

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
double desktop();//function prototype
double laptop();
double tablet();

[Code] ....

View 2 Replies View Related

C++ :: Write A Source Code That Find Smallest / Largest And Average Of Numbers From Array

May 13, 2014

im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.

void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];

[Code]...

View 5 Replies View Related

C Sharp :: How To Code Array In Windows Form Using Listview In Visual Studio 2008

Oct 5, 2013

This is my problem in my subject programming but i dont how to use Array in windows form ... If i run my code i want my Data in listview would not be disappear if i close the form ...?

View 1 Replies View Related

C :: How To Get Scan Code Of ESC Key

Sep 17, 2014

i wrote the following code :

Code:

#include<stdio.h>#include<conio.h>
#include<stdlib.h>
int a[][4] = {15,9,10,25,6,2,4,7,32,19,42,8,21,17,18,0};
void boxes();
void display();
void main()
{int ch,r=3,c=3,t;

[Code]...

not able to esc when i press esc key.how to get rid of this.

View 4 Replies View Related

C++ :: From String To A Code

Apr 17, 2013

I wanna to know how can i get a string from the user and treat it as a c++ code ..is there any way to do that ??

View 7 Replies View Related

C++ :: How To Code AI For RTS Games

Oct 13, 2013

I want to make a RTS game but how can I code an AI for RTS games. How to do that?

View 5 Replies View Related

C++ :: How To Get Source Code From The Web

May 4, 2014

I am making a game and want to make an updater that grabs the source code from a page on the web. Can this use things that are available to all platforms? It could just be something that grabs the text from the page and executing it (maybe using something like Python's exec() command ?) BTW I'm using mac

View 1 Replies View Related

C++ :: Put Code In A Function

Feb 25, 2014

this is my code i want to put the part where i have it do multiplication and addition into functions. and then call them so that it can run the addition and multiplication. Heres my code

# include <iostream>
using namespace std;
int main(){

[Code].....

View 2 Replies View Related

C++ :: DLL Project On Code Blocks

Feb 24, 2015

I'm pretty new to C++ and I'm on Binary Trees in "Jumping into C++"! I've just created a DLL project on Code::Blocks, and I cannot get it to build and run: "You must select a host application to "run" a library..." is the message that I'm getting when I run the main code file. It's had no changes to it (except for a few extra, unnecessary line feeds), and it's the file which Code::Blocks generates on a DLL project.

View 13 Replies View Related







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