answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

Can you increment the value of a variable by 2 using any increment operator?

There is no such increment operator in C language to increment the value of a variable by 2.An increment operator only increments the value by 1.

however you can apply the increment operator twice to get an increment of

3. No: you cannot: ++(++a) won't compile.

Yes. Example: a += 2; but += is not an increment operator, it's a shorthand of a=a+2; just like a++ is a shorthand for a= a+1

Advantages and disadvantages of arrays in java?

Arrays permit efficient (constant time) random access but not efficient insertion and deletion of elements. Consequently, arrays are most appropriate for storing a fixed amount of data which will be accessed in an unpredictable fashion.

Another advantage of arrays that has become very important on modern architectures is that iterating through an array has good locality of reference, and so is much faster than iterating through (say) a linked list of the same size, which tends to jump around in memory. However, an array can also be accessed in a random way, as is done with large hash tables, and in this case this is not a benefit.

Arrays also are among the most compact data structures; storing 100 integers in an array takes only 100 times the space required to store an integer, plus perhaps a few bytes of overhead for the whole array. Any pointer-based data structure, on the other hand, must keep its pointers somewhere, and these occupy additional space. This extra space becomes more significant as the data elements become smaller. For example, an array of ASCII characters takes up one byte per character, while on a 32-bit platform, which has 4-byte pointers, a linked list requires at least five bytes per character. Conversely, for very large elements, the space difference becomes a negligible fraction of the total space.

Because arrays have a fixed size, there are some indexes which refer to invalid elements - for example, the index 17 in an array of size 5. What happens when a program attempts to refer to these varies from language to language and platform to platform.

Program that accepts an input as a decimal number and converts it into a binary expression?

if you're using Java the Integer class has alot of methods that can easely convert to byte

for example:

int s;

Integer i = new Integer (s);

i.byteValue() // returns the same number but as a byte

i.toBinaryString(s) // returns the binary value as a string varibale

otherwise you can construct a loop that constructs a varaible using isOdd and finction ex :

public int binaryVariable (int i){

int m = 1; // increments with each variables

int n = 0; // varies between 0 and 1;

int a =0; // the outcoming number;

while (i>0){

if (isOdd (i)) n =1; // I'm afraid you have to make the isOdd function

else n = 0;

a +=n*m;

m*=10;

i/=2;

}

return a;

}

//hope this has helped

Use of 0x33 in c language?

Is possible. It means hexadecimal, so 0x33 = 3*16 + 3 = 51

Differences between user define function and uild in?

The person who created them.

For example, you don't have to write an 'sprintf'function, because you already have it in the standard libraries.

What do you mean by constant in c language?

Constant in C means the content whose value does not change at the time of execution of a program.There are several types of constants $ they are i>numeric->a.INTEGER b.REAL
ii>character->a.SINGLE CHARACTER b.STRING.

Hope this will help you.

Recursive function in c to compute the number of nodes in a binary tree?

int Nodes (Tree *t)

{

int sum= 0;

if (t) {

sum+=1;

if (t->left) sum += Nodes (t->left);

if (t->right) sum += Nodes (t->right);

}

return sum;

}

Difference between argc and argv?

I really hope you pay more attention to your texts and lessons in the future, anyway:

int argc (Argument Count, note that it is an integer.)

char* argv[] (Argument Value, the actual thing stored there.)

Those are passed to the main function from the operating system so that you can have command line parameters.

Oh and if you really want me to blow your mind, they don't need to be name argc/argv.

int main(int argc, char* argv[])

{

for(a=0;a<=argc;a++){

printf(%s,argv[a]);

}

return 0;

}

is the same as

int main (int foo, char* bar[])

{

for(a=0;a<=foo;a++){

printf(%s,bar[a])

}

return 0;

}

(Which means the prototype for main is usually: int main(int, char**) )

Write an algorithm to search an element in linked list?

To search for an element in a linked list, you iterate the list, looking for the element, and either return the element or an indication that it was not found. for (ptr = first; ptr != null; ptr = ptr.next) if (ptr.value == searchvalue) break; This will either leave ptr with the address of the found element, or null, if not found.

What is the difference between C plus plus and the D language?

D essentially evolved from practical usage of C++ and added features found in other languages including C#, Eiffel, Java, Python and Ruby. D has garbage collection, design by contract, unit testing, true modules, first class arrays, associative arrays, dynamic arrays, array slicing, nested functions, inner classes, closures, anonymous functions, compile time function execution, lazy evaluation, a re-engineered template syntax and integrated inline assembler.

What is an ordered list of data structure using c plus plus?

An ordered list of data in any programming language is simply a sorted array or list. In C++ this can either mean a sorted array, vector, list or forward list.

Why use of external variables is discouraged?

External variables, or global variables, are generally frowned upon because any code with access to the variables can alter the variables in unexpected ways. Object oriented programming addresses this problem by allowing programmers to encapsulate those variables into an object (often a singleton object) which provides far greater control over how those variables may be altered.

What is an evaluation purpose only program?

I means that you are not supposed to use it for any other purpose except for deciding if the program will do what you want.

It is like test driving a car.

What is a fairy loop for?

whos the cat in the hat who played cat in the hat

What is structure in oops?

Structures can be defined as a tool for handling a group of logically related data items. They are user-defined and provide a method for packing together data of different types.

Structure Student

'declaring a structure named Student

Dim StudentId As Integer

Dim StudentName As String

'declaring two fields of different data types in the structure

End Structure

Best Regards

Nikhil Soni