Data organized in ascending or descending oreder?
Data organized in ascending or descending order is called stacking data. Stacking data is usually organized by number or by alphabet.
How can you convert an infix notation to postfix notation?
#include <iostream>
#include <stack>
using namespace std;
int prec (char ch){
// Gives precedence to different operators
switch (ch) {
case '^':
return 5;
case '/':
return 4;
case '*':
return 4;
case '+':
return 2;
case '-':
return 1;
default :
return 0;
}
}
bool isOperand(char ch){
// Finds out is a character is an operand or not
if ((ch>='0' && ch<='9') (ch>='a' && ch<='z'))
return true;
else
return false;
}
string postFix (string infix){
string pfix = "";
stack<char> opstack;
for (int i=0; i<infix.length(); i++){
// Scan character by character
if (isOperand(infix[i]))
{
pfix += infix[i];
}
else if (infix[i] ')')
{
// Retrace to last ( closure
while (opstack.top() != '(')
{
pfix += opstack.top();
opstack.pop();
}
// Remove the '(' found by while loop
opstack.pop();
}
What are C plus plus intrinsic functions?
Most functions are available from libraries, however some functions are built-in to the compiler itself. A built-in function is therefore an intrinsic function.
Some intrinsics are only available as built-in functions while others also have standard function equivalents. You can choose to use some or all intrinsics either by using the #pragma compiler directive or via a compiler optimisation switch, such as /Oi in MSVC++, or indeed both.
Intrinsic functions are typically inline expanded to eliminate the overhead of a function call, and some will also provide information back to the compiler in order to better optimise the emitted code.
Intrinsics affect the portability of code but are generally more portable than inline assembler. Indeed, some architectures do not support inline assembler, thus intrinsics are nothing if not essential where optimal code is a requirement.
Your compiler's documentation should provide a complete list of the intrinsic functions available for each platform it supports, along with the standard function equivalents.
What is the keyword used in C to give space in ASCII?
ASCIIHTMLHTMLDecHexSymbolNumberNameDescription32 20 space
How do you repair an unhandled exception?
You can stop an unhandled exception by handling it. When your program crashes it will tell you exactly where it crashed and what exception it ran into. Dealing with the exception is the hard part. Generally, you want to take one of two approaches. The first is to make sure that the exception cannot happen. You may, for example, have to validate data to make sure that your users aren't allowed to give input which would result in a division-by-zero exception. The second is to allow the exception to be thrown, but use a try-catch block to catch it and print out a useful message instead of crashing. The method you choose will depend on what your program is supposed to do, who is using it, what exceptions are being thrown, where they're being thrown, etc. There's no silver bullet solution for handling an exception.
Write a shell program to check odd or even number?
/*Programming in C...*/
#include
int main(void)
{
int n ;
printf("enter a number :");
scanf("%d",&n);
if(n%2==0)
{
printf("no is even\n");
}
else
printf("no. is odd\n");
return 0;
}
Algoritm for deleting the last element from a list?
Given a list and a node to delete, use the following algorithm:
// Are we deleting the head node?
if (node == list.head)
{
// Yes -- assign its next node as the new head
list.head = node.next
}
else // The node is not the head node
{
// Point to the head node
prev = list.head
// Traverse the list to locate the node that comes immediately before the one we want to delete
while (prev.next != node)
{
prev = prev.next;
}
end while
// Assign the node's next node to the previous node's next node
prev.next = node.next;
}
end if
// Before deleting the node, reset its next node
node.next = null;
// Now delete the node.
delete node;
Why does programmer need variable?
Variables can maintain the same value throughout a program, or they can change values several times, depending on your needs. when you put a variable in a program, the computer recognises the variable and you can change it's value throughout without an error. Note: You can write programs without variables, but their functionality will be quite restricted, like this:
int main (void) { puts ("hello, world"); return 0; }
What are high level programming languages how they differ from assembly languages?
High-level languages are easy to read and write. They are not machine dependent and portable from one computer to another. Assembly languages are machine dependent, easier to read than machine code but it's still not easy to read, and the assembler program translates the assembler program straight into machine code.
KVM switches are available via hardware and now today over IP software is also available...many switch, keyboard and video combinations are possible.
Input and output statements in C?
For input: scanf("%d",&the value u wanna get into pgm); For output: printf("%d",the value u wanna give to out); Note: u ve to be sure in the letter u put after %.because it ll change depends on variable.eg:int,char,floatdouble,string,decimal,hex,oct..etc Rgds, BM
Write a program to detect duplicate elements in array?
The simplest way of doing this is not very efficient, but provides a quick development time. You want to take all of the elements of the array, add them to a Set, then retrieve them as an array again. Note that this will probably not preserve the order of elements in the array.
{
Object[] originalArray; // let's pretend this contains the data that
// you want to delete duplicates from
Set newSet = new HashSet();
for (Object o : originalArray) {
newSet.add(o);
}
// originalArray is now equal to the array without duplicates
originalArray = newSet.toArray();
}
Now the efficient, and more correct, solution.
This one will create a new array of the correct size without duplicates.
{
Object[] originalArray; // again, pretend this contains our original data
// new temporary array to hold non-duplicate data
Object[] newArray = new Object[originalArray.length];
// current index in the new array (also the number of non-dup elements)
int currentIndex = 0;
// loop through the original array...
for (int i = 0; i < originalArray.length; ++i) {
// contains => true iff newArray contains originalArray[i]
boolean contains = false;
// search through newArray to see if it contains an element equal
// to the element in originalArray[i]
for(int j = 0; j <= currentIndex; ++j) {
// if the same element is found, don't add it to the new array
if(originalArray[i].equals(newArray[j])) {
contains = true;
break;
}
}
// if we didn't find a duplicate, add the new element to the new array
if(!contains) {
// note: you may want to use a copy constructor, or a .clone()
// here if the situation warrants more than a shallow copy
newArray[currentIndex] = originalArray[i];
++currentIndex;
}
}
// OPTIONAL
// resize newArray (using _newArray) so that we don't have any null references
Object[] _newArray = new Object[currentIndex];
System.arraycopy(newArray, 0, _newArray, 0, currentIndex);
}
return lets you literally return a value from a function. This allows you to define functions like:
int add(int x, int y)
{
return(x + y);
}
int twoplustwo = add(2, 2);
What is primitive system of measurement?
Solar and Lunar cycles. Some cultures used one or the other for the basis of their yearly calendars.
How will you find the location of an element of an array?
Basically,
&array[i];
That is, the memory location for an array object with index i.
Or, you can do:
(array + i);
Why routine operator maintenance is so important?
Intermittent machines are maintained by closely examining them on a regular basis and replacing any damaged parts. Lubrication and coolants are topped off as needed to keep it running at peak performance.
To find whether a number is odd or even?
The following simply uses the definition of "odd" and "even". Do an integer division by 2. If it is divisible (no remainder), it is even. Else, it is odd. Here is some sample code in Java:
System.out.println(myNumber % 2 == 0 ? "It is even" : "It is odd");
Flow chart to reverse digits of numbers?
ALGORITHM REVERSE
INPUT (string)
"STRINGLENGTH() would be a function that returns the lenght of the string"
FOR (i = STRINGLENGTH(string); i >= 0; i--) BEGIN
DISPAY (string[i])
END FOR
END REVERSE
Write a program in c to find transpose of a matrix using functions?
Sorry to delete the previous version of this program, but this one is much more concise and sophisticated. I have written this program for a 3*3 matrix, but if you want to change it, just enter additional variables to store the order of the matrix and then replace the "3"s of the program with them as needed. It's easy. So here we go:
#include
#include
void swap(int *x,int *y);
main()
{
int i,j,k,m,n;
int matrix[3][3];
printf("Enter the matrix: \n\n");
for (i=0;i<3;++i)
{
printf("\nEnter #%d row: ",(i+1));
for (j=0;j<3;++j)
scanf("%d",&matrix[i][j]);
}
printf("\n\n");
for (j=0;j<3;++j)
{
for (i=0;i<3;++i)
if (i>j)
swap(&matrix[i][j],&matrix[j][i]);
}
printf("The transposed matrix is: \n\n");
for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
printf("%4d",matrix[i][j]);
printf("\n\n");
}
}
void swap(int *x,int *y)
{
int t=*x;
*x=*y;
*y=t;
return;
}
Concept: use order and number of elements of some data structure to control iteration
Two strategies:
Where does the decision point appear in a flow chart?
i want to design a simple flow chart with question point starting from the customer making their initial call and leading to a response by a specialist
Advantages of dynamic memory allocation in data structure?
The main advantage of dynamic memory allocation is flexibility: the sizes of structures (or upper bounds on the sizes) do not need to be known in advance, so any size input that does not exceed available memory is easily handled. There are costs, however. Repeated calls to allocate and de-allocate memory place considerable strain on the operating system and can result in "thrashing" and decreased performance. In addition, one has to be very careful to "clean up" and de-allocate any memory that is allocated dynamically, to avoid memory leaks.
The general rule of thumb is, if you can allocate memory statically, do it, because the result will probably be faster code that is easier to debug. But if you need to handle wide-ranging input sizes, then dynamic memory allocation is the way to do it.