answersLogoWhite

0

Pseudocode: if x > y then return x else return y

Actual code (C++):

return( x>y ? x : y );

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

Find largest value algorithm in c?

** pseudo code ** if array length == 1, return first element else if array length > 1 max = first element for second item to last item if item > max max = item return max else // array length is 0 error


Why is pseudo code called false code?

Pseudo code cannot be processed by a machine, it is solely intended for processing by humans.


How do you write a program in c plus plus to remove fifth element in the array?

To remove any element from an array, you must overwrite every element from that point on with the element that follows it. That is, every element after the removed element must be copied to the preceding element. So to remove the 5th element, you copy the 6th element to the 5th element, the 7th to the 6th, and so on. Once all elements have been copied, you can reduce the array size by one element. Alternatively, you can leave the array size as is and simply maintain a count of the used elements (unused elements will always be at the end of the array).Note that in C++, a vector encapsulates an array of any type and provides member methods for manipulating that array, including the removal of individual elements. While manipulating arrays is a worthwhile exercise in determining "how things work", it's always better to make use of efficient, tried-and-tested code, rather than constantly re-inventing wheels to provide such common functionality.


How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }


Is there an absolute 'right' and 'wrong' way of writing pseudo code?

No. There is no "right way" and "wrong way" of writing pseudo code, let alone qualifying with "absolute". However, a pseudo code is "wrong" if it cannot be understood, or it is incorrect in semantic (what the code tries to describe, solve, etc)

Related Questions

How can the keyword "sorting" be implemented in pseudo code to arrange the elements of an array a of integers in ascending order?

To implement the keyword "sorting" in pseudo code to arrange the elements of an array a of integers in ascending order, you can use the following algorithm: Start by iterating through the array a from the first element to the second-to-last element. Compare each element with the next element in the array. If the current element is greater than the next element, swap their positions. Continue this process until the entire array is sorted in ascending order. Here is a simple example of pseudo code for implementing the sorting algorithm: for i from 0 to length(a) - 1 do for j from 0 to length(a) - i - 1 do if aj aj 1 then swap(aj, aj 1) end if end for end for This pseudo code represents a basic implementation of a sorting algorithm to arrange the elements of an array in ascending order.


Find largest value algorithm in c?

** pseudo code ** if array length == 1, return first element else if array length > 1 max = first element for second item to last item if item > max max = item return max else // array length is 0 error


Why is pseudo code called false code?

Pseudo code cannot be processed by a machine, it is solely intended for processing by humans.


How does pseudo code operate?

It doesn't. Pseudo code isn't a programming language, it is just there to give an idea of how you could write a program.


How do you write a program in c plus plus to remove fifth element in the array?

To remove any element from an array, you must overwrite every element from that point on with the element that follows it. That is, every element after the removed element must be copied to the preceding element. So to remove the 5th element, you copy the 6th element to the 5th element, the 7th to the 6th, and so on. Once all elements have been copied, you can reduce the array size by one element. Alternatively, you can leave the array size as is and simply maintain a count of the used elements (unused elements will always be at the end of the array).Note that in C++, a vector encapsulates an array of any type and provides member methods for manipulating that array, including the removal of individual elements. While manipulating arrays is a worthwhile exercise in determining "how things work", it's always better to make use of efficient, tried-and-tested code, rather than constantly re-inventing wheels to provide such common functionality.


How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }


What is the basic Difference between flow chart and pseudo-code?

what's the difference between flow chart and structure diagrams and pseudo code


Is there an absolute 'right' and 'wrong' way of writing pseudo code?

No. There is no "right way" and "wrong way" of writing pseudo code, let alone qualifying with "absolute". However, a pseudo code is "wrong" if it cannot be understood, or it is incorrect in semantic (what the code tries to describe, solve, etc)


What are the pseudocode keywords for loop?

Pseudo code does not have key words, you make it up, that's why it is pseudo.


What is pseudo code algorithm for create a linked list with a header and insert a four numbers to the list?

pseudo code algorithm to create a linked list


What is the difference of source code object code and pseudo code?

Source code is a sequence of executable instructions written in a particular language. Pseudo code is a sequence of non-executable instructions. It is also called algorithm written in plain English


How can i write pseudo code for C plus plus if i haven't even wrote the program yet?

You are going about this backwards. First, define the program. Second, describe its algorithm. Third, if needed, write pseudo code. (Sometime, algorithm and pseudo code is the same process.) Fourth, or third, write real code.