What does printf function return?
Two possibilities: on success, it'll return the amount of characters printed. On failure, a negative number is returned.
What statement is used to skip a part of loop?
The continue statement is used to skip the balance of a loop.
What if the elements are repeated in binary search?
You will find one of them (not necessarily the first or the last).
a regular and imposing arrangement; disposition in regular lines
Difference between message oriented middleware and remote procedure call?
Feature MOM RPC
Metaphor post office like Telephone like
Cilent server
time relationships ASynchronous Synchronous
Client server
sequence No sequence server must first comes up
before the client talks to it.
Partner needed No Yes
Message filtering yes No
Load
balancing Single queue is needed Require TP monitor
implement FIFO policy
Performance Slow Fast
Style queued call return
What are the uses of sentinel value?
A sentinel value is a value that is not supposed to change. It can be allocated along with, and used before the beginning and after the ending of a region of memory to detect if the program logic modified memory outside of the intended region. Most compilers and run-time libraries will do this automatically when you do a debug compile/link.
Why does LIFO order follows in stack and why does FIFO order follows in queue?
LIFO and stack are synonyms, so are FIFO and queue.
How do you draw a cycle in a c program?
/*PROGRAM TO IMPLEMENT GAUSS-jordan method.
#include
#define MX 20
main()
{
float a[MX] [MX+1],m,p;
int i,j,k,n;
puts("\n how many equations?:");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("Give the coefficients of the equation no%d:\n",i+1);
for(j=0;j<=n;j++)
scanf("%f",&a[i][j]);
}
for(k=0;k<=n-1;k++)
{
for(i=0;i<=n-1;i++)
{
m=a[i][k]/a[k][k];
p=a[k][k];
for(j=k;j<=n;j++)
{
if(i==k)
a[i][j]=a[i][j]/p;
else
a[i][j]=a[i][j]-m*a[k][j];
}
}
}
for(i=0;i<=n-1;i++)
printf("\n X[%2d]=%5.2f",i,a[i][n]);
}
How sorted data effects binary search tree?
If the data is sorted, you don't need a tree, you can use a sorted array with constant time random access and zero overhead. To perform a binary search, start with the middle element (what would be the root of a balanced tree). If that's not the value you're looking for, repeat the search with the left subarray if the middle element is larger, or the right subarray if not. This reduces the number of elements to search by half on each iteration. If the chosen subarray is empty, the value you're looking for does not exist. If the value does exist, you will eventually find it in the middle of the remaining subarray.
Write a program to dycrypt the text kpfkc to get original string India using string concept in c?
char cyphertext[] = "kpfkc";
char plaintext[sizeof(cyphertext)];
int i;
for (i=0; i<sizeof(cyphertext); i++) plaintext[i] = cyphertext[i] - 2;
Note: This is not portable, and depends on the USASCII character set.
Difference between top down and bottom up parsing in compiler design?
Bottom-up parsing
This approach is not unlike solving a jigsaw puzzle. We start at the bottom of the parse tree with individual characters. We then use the rules to connect the characters together into larger tokens as we go. At the end of the string, everything should have been combined into a single big S, and S should be the only thing we have left. If not, it's necessary to backtrack and try combining tokens in different ways.
With bottom-up parsing, we typically maintain a stack, which is the list of characters and tokens we've seen so far. At each step, the stack is "reduced" as far as possible by combining characters into larger tokens.
Top-down parsing
For this approach we assume that the string matches S and look at the internal logical implications of this assumption. For example, the fact that the string matchesSlogically implies that either (1) the string matches xyz or (2) the string matchesaBC. If we know that (1) is not true, then (2) must be true. But (2) has its own further logical implications. These must be examined as far as necessary to prove the base assertion.
Example
String is acddf.
Steps
· Assertion 1: acddf matches S
oAssertion 2: acddf matches xyz:
oAssertion is false. Try another.
oAssertion 2: acddf matches aBC i.e. cddf matches BC:
§ Assertion 4: ddf matches eg:
§ False.
§ Assertion 4: ddf matches df:
§ False.
§ Assertion 4: df matches eg:
§ False.
§ Assertion 4: df matches df:
§ Assertion 4 is true.
oAssertion 2 is true.
· Assertion 1 is true. Success!
Parse trees
S
|
S
/|\
a B C
| |
S
/|\
a B C
| |
c
S
/|\
a B C
/| |
c d
S
/|\
a B C
/| |\
c d d f
Binary search iterative method over recurssive method?
#include <iostream>
#include <conio.h>
int linearSearch( const int array[], int length, int value);
int main()
{
const int arraySize = 100;
int a[arraySize];
int element;
for( int i = 0; i < arraySize; i++)
{
a[i] = 2 * i;
}
element = linearSearch( a, arraySize, 10);
if( element != -1 )
cout << "Found value in element " << element << endl;
else
cout << "Value not found." << endl;
getch();
return 0;
}
int linearSearch( const int array[], int length, int value)
{
if(length==0) return -1;
else if (array[length-1]==value) return length-1;
else return urch( array, length-1, value);
}
it is in c++ language ,u can change it to c by including stdio.h ,printf & scanf.....i think it wud be beneficial
have a look their too. similar program like that and easy understanding
http://fahad-cprogramming.blogspot.com/2014/02/linear-search-program-in-c-using.html
What variable keeps a running total?
The answer is "an accumulator."
"A running total is a sum of numbers that ACCUMULATES with each iteration of a loop. The variable used to keep the running total is called an accumulator."
It can be any variable you want! It could be total, tot, etc. Here is an example:
total = 0
randoms = [random.randRange(0, 99999)] * 100 # Creates a list of 100 random numbers
for number in randoms:
total += number
print(total) # Py3k print statement. Sample output: 35460
How do you execute 2 for loops together?
If you mean how do you simultaneously execute 2 for loops, you cannot. At best you can execute 2 for loops concurrently, where each loop executes (independently) within two separate threads.
It is possible to execute two loops within the same statement, however this is really just one loop based upon two conditions:
int x, y;
for (x=0, y=0; x<100 && y<100; ++x, ++y) {
/* ... */
}
You probably mean how do you execute a loop within a loop (a nested loop). this is achieved as follows:
int x, y;
for (x=0; x<100; ++x) {
for (y=0; y<100; ++y) {
/* ... */
}
}
Note that the body of this loop will execute 100 x 100 = 10,000 times.
What are the design issue for array?
What is its size? How is its size determined and when (compile/run-time). What does the software using the array do when the array is empty? partially full? full? Avoid the software addressing elements of the array which are undefined, or addressing elements outside the bounds of the array When and who is responsible for allocating and freeing memory when the array is no longer needed (program or called procedure start/termination) or some other time determined during program execution. If the array is implementing a data structure such as a stack, queue, dequeue, list, etc. What is its implementation of the usual data structure operations, Create, Empty, List Items, Top, First, Last, Next, etc.
Double-ended queue using c language?
/* c++ program to implement double ended queue using doubly linked list with templates*/
#include
#include
#include
template
struct node
{
t data;
node
node
};
template
class dequeue
{
private:
node
public:
dequeue()
{
front=rear=NULL;
}
node
{
node
newnode->llink=NULL;
newnode->rlink=NULL;
return newnode;
}
void insfrnt();
void insrear();
void delfrnt();
void delrear();
void disfrnt();
void disrear();
};
template
void dequeue
{
node
cout<<"Enter The Element That Has To Enqueued At The Front"<
if(front==NULL && rear==NULL)
front=rear=newnode;
else
{
newnode->rlink=front;
front->llink=newnode;
front=newnode;
}
}
template
void dequeue
{
node
cout<<"Enter The Element That has to be Enqueued at the Rear"<
if(front==NULL && rear==NULL)
front=rear=newnode;
else
{
rear->rlink=newnode;
newnode->llink=rear;
rear=newnode;
}
}
template
void dequeue
{
if(front==NULL)
cout<<"Dequeue Underflow"<
{
node
temp=front;
if(front==rear)
front=rear=NULL;
else
{
front=temp->rlink;
front->llink=NULL;
}
cout<
}
}
template
void dequeue
{
if(rear==NULL)
cout<<"Dequeue Underflow"<
{
node
temp=rear;
if(front==rear)
front=rear=NULL;
else
{
rear=temp->llink;
rear->rlink=NULL;
}
cout<
}
}
template
void dequeue
{
if(front==NULL)
cout<<"Dequeue Underflow"<
{
node
temp=front;
cout<<"front";
while(temp!=NULL)
{
cout<<"->"<
temp=temp->rlink;
}
cout<<"<-rear"<
}
template
void dequeue
{
if(rear==NULL)
cout<<"Dequeue Underflow"<
{
node
temp=rear;
cout<<"rear";
while(temp!=NULL)
{
cout<<"->"<
temp=temp->llink;
}
cout<<"->front"<
}
void main()
{
dequeue
dequeue
dequeue
int choice;
do
{
clrscr();
cout<<"DEQUEUE :"<
switch(choice)
{
case 1:
clrscr();
int chi;
do
{
cout<<"\t======================="<
switch(chi)
{
case 1: dq_int.insfrnt();
break;
case 2: dq_int.insrear();
break;
case 3: dq_int.delfrnt();
break;
case 4: dq_int.delrear();
break;
case 5: dq_int.disfrnt();
break;
case 6: dq_int.disrear();
break;
}
}
while(chi<=6);
break;
case 2:
clrscr();
int chF;
do
{
cout<<"\t======================="<
switch(chi)
{
case 1: dq_float.insfrnt();
break;
case 2: dq_float.insrear();
break;
case 3: dq_float.delfrnt();
break;
case 4: dq_float.delrear();
break;
case 5: dq_float.disfrnt();
break;
case 6: dq_float.disrear();
break;
}
}
while(chi<=6);
break;
case 3:
clrscr();
int chc;
do
{
cout<<"\t======================="<
switch(chc)
{
case 1: dq_char.insfrnt();
break;
case 2: dq_char.insrear();
break;
case 3: dq_char.delfrnt();
break;
case 4: dq_char.delrear();
break;
case 5: dq_char.disfrnt();
break;
case 6: dq_char.disrear();
break;
}
}
while(chi<=6);
break;
case 4: exit(0);
break;
}
}
while(choice<=3);
}
Which member can not be access from main in c plus plus?
A private member can only be accessed from within a method of the class.
(Not 100% certain what the question means. If this answer is not sufficient, please restate the question, giving more details as to what is being asked.)
1101 in 4 bits,
11111101 in 8 bits,
and so on: add leading 1's as necessary