What is the meaning of the menu driven program?
Menu-driven simply means you execute the application's commands by selecting them from a menu, as opposed to command-driven whereby you enter (type) the commands manually.
What is the maximum number of nodes on a given level of a binary tree?
Level N of a binary tree has, at most, 2^N nodes. Note that the root node is regarded as being level 0. If we regard it as being level 1, then level N would have 2^(N-1) nodes at most.
How do you download c plus plus on vista?
You cannot download a programming language, but you can download compilers. Check the attached link.
What is the C source code for indexed file allocation?
int main (void)
{
puts ("File allocation methods");
return 0;
}
Explain the Cursor implementation of linked list?
The only difference between a link list and the cursor implementation of a linked list is that the curse implementation makes it a link list with different linked node methods. A cursor implementation of linked list involves using several nodes with the "next" pointer going to the index to trigger another node in the list.
How do you use gotoxy in for loop?
Avoid using goto -- it's a sign of bad programming. apart from the risk of jumping over vital memory cleanup code, your code will be that much harder to follow.
Replace all the gotos with function calls or place non-duplicate code inline within the loop itself. To conditionally exit a loop prematurely, use break, not goto. Place the break immediately after the function call or immediately after the inline code.
Why you use function prototype and function definition in c language program?
Prototypes and definitions are usually kept separate because consumers of functions and classes are not remotely interested in the implementation of the functions or classes, only in their signatures. In some cases, the implementations will be contained in a library (lib) so the implementation source code may not even be available to consumers.
By keeping the prototypes in a separate header, consumers simply need to include the header to make use of the declarations it contains, just as if they'd written all the forward declarations themselves (that is in fact what it means to include a file in your source files). The prototype alone is sufficient to determine how the function or class is used, and the header usually includes documentation either in the header itself or as a separate file. However consumers are only concerned with what a function or class does, not how they do it, so the implementation itself is of little importance.
What type of data is held in a string?
String in C is basically a Character 1-D array, whose last character is a NULL ['\0'].
It is declared as follows:
char array_name[size];
Ex.
char wiki[10];
Sample do while loop in turbo c?
int main (int argc, char **argv)
{
int i=0;
do printf ("%2d. %s\n", i, argv[i]); while (++i<argc);
return 0;
}
How individual elements are identified of an array in c?
Individual elements are identified by address. Unlike ordinary variables, we can't identify them by name because array elements are anonymous; they have no name. However, we always know the start address of the array (which can be named) and every element in the array can be referred to by its zero-based offset from this address. That is, the first element is offset 0 elements from the start address because there are zero elements before it. By the same token the nth element is offset n-1 elements from the start address because there are n-1 elements in front of it.
int a[100];
int* p1 = a + 0; // refers to the 1st element (1-1=0)
int* p2 = a + 5; // refers to the 6th element (6-1=5)
int* p3 = a + 99; // refers to the 100th element (100-1=99), the last element
int* p4 = a + 100; // refers to one-past-the-end of the array
Note that p4 is valid because that address is guaranteed to exist even though it is physically beyond the bounds of the array. Although valid, we must never dereference that address because it is not guaranteed to belong to our program. However, we often use the one-past-the-end of a sequence in algorithms that use the end iterator to denote the end of a half-closed range denoted [begin:end). For instance, the following algorithm provides the most efficient means of linearly searching for a given value within any given contiguous sequence of an array, returning the end iterator if the value does not exist:
int* find (int* begin, int* end, int value) {
// search every element to find the value, unless we reach the end iterator
while (begin!=end && *begin!=value) ++begin;
return begin;
}
// search for the value 42 within the whole array
int* i1 = find (a, a+100, 42);
if (i1 == a+100) {
// the value was not found
} else {
// the value was found
}
int*_t i2 = find (a, a+10, 42); // search for the value 42 within the first 10 elements only...
They array suffix operator [] provides a more intuitive means of referring to the individual elements of an array without resorting to pointer arithmetic:
// initialise the array referred to by a of length s elements with the value v
void initialise_all (int* a, size_t s, int v)
{
for (size_t idx=0; idx<size; ++idx) // idx is the zero-based index
{
a[idx] = value;
}
}
initialise (a, 100, 42); // assign the value 42 to all elements of a
Note that the pointer arithmetic still occurs, it's just hidden from the programmer. The array suffix operator is merely sugar-coating. As far as the compiler is concerned, the above is equivalent to the following:
// initialise the array referred to by a of length s elements with the value v void initialise_all (int* a, size_t s, int v)
{
for (size_t idx=0; idx<size; ++idx) // idx is the zero-based index
{
*(a+idx) = value; // pointer arithmetic
}
}
A good compiler will translate the above into the more succinct and highly efficient version:
// initialise the array referred to by a of length s elements with the value v
void initialise_all (int* begin, int* end, int val)
{
while (begin!=end) *(begin++) = val;
}
Although more difficult to read, explicitly using pointer arithmetic yields efficient code regardless of a compiler's ability to optimise your code behind the scenes. However, with modern compilers, there should be no difference to the resultant code.
Is a wildcard for more than one character?
It depends on where you are using it. Back in the DOS days, a * meant multiple characters and a ? meant one character.
I've seen software that says to use *, ?, and % for wildcards, but they were all for multiple characters.
So it really depends on what you are using. Not everything supports a single wildcard.
Why does Java support multilevel inheritance?
Because it is one of the most important and widely used inheritance concepts in Java. In multi level inheritance a class directly inherits features from one class and indirectly inherits features form other classes that are in the inheritance hierarchy.
#include
void main ()
{
int i = 0; // This is initialising variables.
int n = 0;
int n2 = 0;
printf("n\t\tn^2\t\t\n______________________________\n"); // This creates the top line of the table, the "____" creates a line, the \t tabs across to create the headers making the heading look neater and more presentable.
for (i=0; i<=10; i=(i+1)) //setting conditions for loop
{
n2 = (i*i); // This is creating the second variable n2.
printf("%d\t\t%d\t\t\n", i, n2); // assigning variables n and n2 to rows.
}
system("pause"); // Pausing the program so I can view it in the execution window.
}
That should be it but correct me if im wrong.
What are the advantages of structures of C language?
we can create a program which is useful for others and can resolve the problem in less time
What is the meaning of final keyword in Cplusplus language?
Actually, when you declare a variable as 'final' then the value assingned to the variable does not changes throughout the program.
For example,
class d
{
public final int n=10;
}
In this class d, the value of 'n' would be '10' & its value cannot not be altered by any function declared within the class.
Types of programming languages their merits and demerits?
Binary-Incredibly fast and difficult, just 1s and 0s.
Assembly-Very fast and a tiny bit less difficult, it's still incredibly hard to understand.
Compiled-Easy-ish to understand, fast, and reliable, good for big projects.
Byte-Code-Easy, medium-fast and reliable, also good for big projects.
Interpreted-Very easy, will take you a day or 2 to learn the basics, very useful for math class ;).
Markup-A newborn baby could code this with ease, just for static webpages mostly.
What is pointer initialization?
Assigning an initial value to a pointer variable. Example:
int *p= NULL;
What is the example of binary operator?
There are many: addition, subtraction, multiplication and division are the most common. Each of these operators acts on two numbers to produce a third (which may not be different).
Write a pseudo logic to check whether a string is palindrome or not?
Prepare the string for processing: Remove all punctuation from the string (e.g., commas, hyphens, whitespace, etc).
Convert to the same case (e.g., lower-case).
Instantiate two pointers, one pointing at the first character, the other pointing at the last character.
Process:
If the two pointers are pointing at the same position or have crossed each other, the string is a palindrome.
Otherwise, compare the characters being pointed at. If they are not equal, the string is not a palindrome.
Otherwise, move both pointers one position towards the middle of the string and repeat the process.
Program to perform Fibonacci search in c language?
#include<stdio.h>
int main(){
int a[10],i,n,m,c=0;
printf("Enter the size of an array: ");
scanf("%d",&n);
printf("Enter the elements of the array: ");
for(i=0;i<=n-1;i++){
scanf("%d",&a[i]);
}
printf("Enter the number to be search: ");
scanf("%d",&m);
for(i=0;i<=n-1;i++){
if(a[i]==m){
c=1;
break;
}
}
if(c==0)
printf("The number is not in the list");
else
printf("The number is found");
return 0;
}
How do you sort the name alphabetically in c or c plus plus?
#include
#include
// prints a 2d array of strings
void print2d(const std::string* arr, const size_t rows, const size_t cols)
{
for(size_t row=0; row { for(size_t col=0; col { std::cout< } std::cout< arr+=cols; } } int main() { // example 2d array const size_t rows = 10; const size_t cols = 2; std::string names[rows][cols] = { "John", "Wayne", "Johnny", "Depp", "Michael", "Douglas", "Anthony", "Hopkins", "Kirk", "Douglas", "Daniel", "Craig", "Tom", "Hanks", "Sean", "Connery", "Sean", "Bean", "Adam", "Baldwin" }; std::cout<<"\nUnsorted:\n"< print2d( names[0], rows, cols ); std::cout< // Sorting algorithm: uses insertion sort for(size_t row=1; row { // copy the current name std::string copy[2]; copy[0] = names[row][0]; copy[1] = names[row][1]; // store the gap row size_t gap=row; // store the compare row (always the row above the gap row) size_t cmp=gap-1; // repeat while the gap row is non-zero and the copy name // is less than the compare name (comparing surname first) while(gap && (copy[1] { // move the compare name into the gap names[gap][0]=names[cmp][0]; names[gap][1]=names[cmp][1]; // move the gap up one row --gap; --cmp; } // insert the copy into the gap row names[gap][0]=copy[0]; names[gap][1]=copy[1]; } std::cout<<"\nSorted:\n"< print2d( names[0], rows, cols ); std::cout< } Output Unsorted: John Wayne Johnny Depp Michael Douglas Anthony Hopkins Kirk Douglas Daniel Craig Tom Hanks Sean Connery Sean Bean Adam Baldwin Sorted: Adam Baldwin Sean Bean Sean Connery Daniel Craig Johnny Depp Kirk Douglas Michael Douglas Tom Hanks Anthony Hopkins John Wayne