What is queue explain the basic element of queue?
The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )
The set of datatypes and the definition of each member is dependent on hardware, the language standard, and the language implementation. Not knowing which language the question relates to is particularly limiting.
In Java, a long consists of 8 bytes. This is also generally true for C and C++, depending upon the compiler used. See the related links for further details.
What are the four types of grammars used in compiler?
-Single pass compiler
-Multi pass compiler
-Cross compiler
-Optimizing compiler
What is ampersand in C Language?
The ampersand '&' has many uses in the C++ language:
The single ampersand can be used to reference the pointer address of a pointer:
int* pointer;
int* anpointer;
anpointer = &pointer;
This example, although perhaps not valid, shows that the anpointer reference is now the same as the reference to the pointer memory address.
The single ampersand can also be used to reference an object in a function:
void function( int param1, int param2, int &reference );
If this function were to be called, and the reference object altered within the function, the actualy object that was passed into the function would be altered.
The double ampersand '&&' specifies that the left AND the right concepts must both be true before the whole statement is true. For example:
if( conceptA true )
{
conceptC = true;
}
Why is C plus plus such a robust programming language?
Borland's implementation of C++ was never regarded as the Bible of Computer Programming (whatever that means). If it were we'd probably still be using it today, but it was rendered obsolete in 1997 when Borland C++ Builder superseded it.
What is difference between constant in c plus plus and final in java?
The final keyword can be used to modify a class, method, or variable.
When used on a variable, it means that variable cannot be changed once set.
When used on a method, it means that no subclasses may override that method.
In computer science, runtime or run time describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). The term is also used as a short form when referring to a runtime library (without a space), a program or library of basic code that is used by a particular computer language to manage a program written in that language while it is running. A runtime environment is a virtual machine state which provides software services for processes or programs while a computer is running. It may pertain to the operating system itself, or the software that runs beneath it.
Quite a few. Some of them are:
, () [] & * . ->
+ ++ += - -- -=
* / % *= /= %=
! == <= >= < > !=
<< >> >>= <<=
& | ^ ~
&&
What are the disadvanteges of high level programming language?
Depends on the purpose of the program your creating. Generally speaking high level languages require far more system resources than low level languages. So if you were writing embedded code on a microcontroller, writing in Java would be a big no no as you'd barely be able to do anything whereas in C or assembler you could write a functional and useful program. (C is often used for faster development and high accuracy whereas assembler can be moulded to high performance low accuracy).
What is the importance of an array?
The primary use of an array is create a collection of anonymous variables of the same type.
Although we can name all our variables at compile time, we can only do so if we know precisely how many variables we require at compile time. Even then, if the number of variables is large enough, naming and referring to each one by name can be impractical; imagine naming a million integer variables individually!
Arrays allow us to refer to a collection of variables through a single name; the array name. Every variable in an array must be of the same type. The variables are known as "elements" and the elements must be stored contiguously (one after the other). The array name serves as a reference to the start address of the array and thus to the first element of the array. All other elements are anonymous.
For any given type T, the type T[n] is an array of n elements of type T, where n is a constant. The number of elements in an array is limited only by available memory, bearing in mind that memory must be allocated as a single contiguous block. Arrays can also be disk-based however the same principals apply to both disk-based and memory-based arrays.
Consider the following declaration:
int x[1000];
The name x refers to an array of 1000 integer elements. The amount of memory physically allocated to this array is 1000 * sizeof (int) bytes. If we suppose that sizeof (int) is 4 bytes, the amount of memory allocated will be exactly 4000 bytes. The compiler can work this out from the declaration alone.
The compiler can also work out the address of every element within the array using a zero-based index. We use the subscript operator to refer to individual elements by index:
x[10] = 42;
Here, we've assigned the value 42 to the 11th element (index 10). The compiler calculates the address of the 11th element using trivial pointer arithmetic:
sizeof (int) * 10 + x;
Note that x, &x and &x[0] all refer to the same memory address (the address of the 1st element).
Arrays may be fixed-length or variable-length. We use fixed-length arrays when we know exactly how many elements we need at compile time. Fixed-length arrays may be allocated statically (in the program's data segment), on the call stack or on the heap (the free store). Variable-length arrays can only be allocated on the heap.
To create an array on the heap we need to use a pointer variable to keep track of the start address:
void f (const int elements) {
int* p1 = malloc (1000 * sizeof (int)); // fixed-length array on the heap
int* p2 = malloc (elements * sizeof (int)); // variable-length array on the heap
// use arrays...
p1[10] = 42;
// ...
free (p2);
free (p1);
}
Note that we can use the array subscript operator with any pointer type except void*. This is because the compiler needs to know the length of the type being pointed at, but sizeof (void) is meaningless.
Whenever we pass arrays to functions we must always pass the length of the array through a separate argument. This is because an array implicitly converts to a pointer to the first element and we cannot determine how many elements are actually being referred to from the pointer alone:
void f (int a[], unsigned len) {
for (int i=0; i<len; ++i) printf ("%d\n", a[i]);
}
The only exceptions to this are null-terminated arrays or arrays that use some pre-determined value to mark the end of the array. Character arrays (strings) are a typical example:
void g (char* str) {
printf ("%s", str); // Note: str must be null-terminated!
}
Note that, by convention, we use char* when referring to a null-terminated string rather than char[]. The latter is conventionally used to denote a non-null terminated string in which case we must also pass the string's length:
void h (char str[], unsigned len) { for (int i=0; i<len; ++i) printf ("%c", str[i]);
}
How can you pass variable arguments to a function in c?
## posted BY Pulkit ok. so to declare variable argements in arguments use this: ret_type function_name( . . .); using these three dots will tell compiler to include variable aarguments. Note: this feature has been included in New version of C,, this is not available in old compiler. thankx guys n grls ## posted BY Pulkit ok. so to declare variable argements in arguments use this: ret_type function_name( . . .); using these three dots will tell compiler to include variable aarguments. Note: this feature has been included in New version of C,, this is not available in old compiler. thankx guys n grls
Yes.
With a linked list, each node in the list points to the next node, except the tail which points to nothing. To maintain the list we must keep track of the head node at all times. In order that all insertions and extractions occur in constant time, all insertions and extractions must occur at the head. Thus when we insert a new node, it simply points to the head and then becomes the head. And to extract the head, the next node from the head becomes the head before we delete the old head. Since all insertions and extractions occur at the head, linked lists can be used to implement a stack (last in, first out). We can also traverse the list from the head and insert at any point in the list in order to maintain a sorted order, however this cannot be done in constant time and there are more efficient ways of maintaining order than by a linked list.
In order to implement a queue (first in, first out) using a linked list, we need to maintain a pointer to the tail as well as the head. Extractions still occur at the head, as before but insertions now occur at the tail, where the tail points to the new node which then becomes the tail. However, rather than maintaining a separate pointer for the head, we can simply point the tail at the head, thus creating a circular linked list. Since the tail always points at the head we have constant time access to both through a single pointer. Insertions are only slightly more complicated in that new nodes must first point at the head node (which they can copy from the tail node) before the tail node points to the new node which then becomes the tail.
A "square" is a flat shape, depicted on a piece of paper or other flat surface.
Since it has only two dimensions, it has no volume. In other words, a square
can't hold any water.
Why do need Unicode when you have Ascii?
ASCII only has 127 standard character codes and only supports the English alphabet. While you can use the extended ASCII character to provide a set of 256 characters and thus support other languages there's no guarantee that other systems will use the same code page, so the characters will not display correctly across all systems (the characters you see will depend upon which code page is currently in use). Moreover, some languages, particularly Chinese, have thousands of symbols that simply cannot be encoded in ASCII.
UNICODE encoding supports all languages and the first 127 symbols are also the same as ASCII, so all characters appear the same across all systems. UTF8 is the most common UNICODE encoding in use today because it uses one-byte per character for the first 127 characters and is therefore fully compliant with non-extended ASCII. If the most-significant bit is set then the character is represented by 2 or more bytes, the combination of which maps to the UNICODE encoding.
How do you make flowchart of ascending order using raptor?
Hey sunil i have an idea about mode that is more repeated data is mode ok
na
Example in the series 2,4,5,2,4,5,2,4,24,22,2,2,7,8,9,2 Mode for this data is 2 i.e. Answer is 2
How are Structure passing and returning implemented by the complier?
When structures are passed as arguments to functions, the entire structure is typically pushed on the stack, using as many words as are required. (Programmers often choose to use pointers to structures instead, precisely to avoid this overhead.) Some compilers merely pass a pointer to the structure, though they may have to make a local copy to preserve pass-by-value semantics. Structures are often returned from functions in a location pointed to by an extra, compiler-supplied ``hidden'' argument to the function. Some older compilers used a special, static location for structure returns, although this made structure-valued functions non-reentrant, which ANSI C disallows
How do you Write a program in c to calculate the sum of two integers?
/*use "c-free" compiler*/
#include <stdio.h>
main()
{
int a,b,c;
printf("enter the value of a & b");
scanf("%d%d",&a,&b);
c=a+b;
printf("sum of the two numbers is a+b- %d",c);
getch();
}
It is the combination of same data type or if same data is needed more then none time then we use array.
Types Normally there are two types of array.
(1) One dimensional array
(2) Two dimensional array
(1) One dimensional array: -
This array is in form a list (vertical\Horizontal) the data input output or process in one dimensional array with the help of loop.
The syntax of one dimensional array will be as:
Array name [strength]
For example
A [5];
The structure of above syntax will be as:
A (0)
A (1)
A (2)
A (3)
A (4)
(2) Two dimensional array: -
Two dimensional array is also called a table because it consist of rows and columns. The syntax of two dimensional arrays will be as:
Data type array name [rows] [columns]
For example
Int [3] [2];
The structure of above syntax will be as:
A [0] [0] A [0] [1]
A [1] [0] A [1] [1]
A [2] [0] A [2] [1]
The data input output are process in this array with the help of nested loop.
Write a program to print first 'n' Fibonacci 100 numbers?
#include<stdio.h> #include<conio.h> void fibo(int); void main() { int num; clrscr(); printf("\n\t Enter number of elements in series : "); scanf("%d",&num); if(num>0) fibo(num); else printf("\n\t Please enter positive number "); } void fibo(int num) { int a=0,b=1,c=0; if(num==1) printf("\n%d",a); if(num>=2) printf("\n%d\t%d\t",a,b); for(;num>2;num--) { c=a+b; a=b; b=c; printf("%3d\t",c); } getch(); }
Does The statements within a while loop execute at least once?
No. If the loop condition is not satisfied then the loop would not be executed even once.
while(condition)
{
.....
/statements
.....
}
here,when the condition is true then the statements will be executed. Otherwise they would be skipped without being executed.
Only for do.. while loops this execution at least once holds good.
Use an else if immediately after the body of an ifwhen you have more than one expression to evaluate. Expressions are evaluated in sequence (top to bottom) and the first evaluation that is true (non-zero) will be the one that executes the statements in its body. Any and all of the remaining expressions are ignored, even if they would have evaluated true.
In the following example, x, y and z are random integers that could be 0 or 1. We evaluate them one by one looking for the first that is non-zero. The comments show what we know to be true about X, Y, and Z at that point, based upon the evaluations that came before.
if( x=1 )
{
// X is definitely 1, but Y and Z might also be 1.
// do something..
}
else if( y=1 )
{
// X is not 1, but Y is definitely 1. Z might also be 1.
// do something else..
}
else if( z = 1 )
{
// Neither X nor Y is 1, but Z definitely is 1.
// do something else..
}
else
{
// X, Y and Z are all 0.
// when all else fails...
}
How do you write a C program to print the diagonal element of a NxN matrix?
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],r,c;
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{
printf("\n enter the value=");
scanf("%d%d",&a[r][c],&b[r][c]);
}
}
printf("\n first matrix=\n");
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{
printf("%d\t",a[r][c]);
}
printf("\n");
}
printf("\n scond matrix=\n");
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{printf("%d\t",b[r][c]);
}
printf("\n");
}
printf("\n sum of given matrix=\n");
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{
c[r][c]=a[r][c]+b[r][c];
printf("%d\t",c[r][c]);
}
printf("\n");
}
getch();
}
How many times will a for loop be executed?
As many times as necessary. There is no practical limit because all loops rely on a control expression that can only evaluate true or false. So long as the control expression evaluates true, the loop will just keep iterating. The canonical example is the infinite loop:
while (true) {
// ...
}
The control expression never evaluates false, so the only way to break out of this loop is from within the body of the loop itself. Although we typically use infinite loops when the control expressions are far too complex to be expressed as a simple expression in the while statement, we can easily avoid this by placing those control expressions in a function. For example, if the control expressions depend on three variables, a, b, c, we can pass those variables to a predicate function that returns true or false:
while (evaluate (a, b, c));
Here, the overall complexity of the control expression is hidden within the evaluate function, greatly simplifying the calling code.
Write a c program to find the maximum of three numbers using parameter passing?
#include<stdio.h> #include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("enter the values of a,b,c");
scanf("%d,%d,%d",&a,&b,&c);
if(a>b)
{if (a>c)
{
printf("a is big");
}
else
{
printf("c is big");
}
}
else
{
if (b>c)
{
printf("b is big");
}
else
{
printf("c is big");
}
}
printf("a=%d/nb=%d/nc=%d",a,b,c);
getch();
}
/*or you can make it in another way*/
#include<stdio.h>
main()
{
int a,b,c;
printf("enter the values of a:");
scanf("%d",&a);
printf("enter the values of b:");
scanf("%d",&b);
printf("enter the values of c:");
scanf("%d",&c);
if(a>b)
{if (a>c)
{
printf("a is big");
}
else
{
printf("c is big");
}
}
else
{
if (b>c)
{
printf("b is big");
}
else
{
printf("c is big");
}
}
return 0;
}