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

Where headers files are generally stored?

It depends on the header file and on the general organization of the project.

System header files, such as stdio.h or windows.h, are stored in a directory that the compiler knows about, but that you don't need to even think about.

Library header files are either stored in the same place that system header files are stored, or they are stored in a place reserved for the particular library. In the latter case, there will usually be build parameters that identify the header files and their associated library files.

User header files are either stored in the same directory as the source files, or they can be stored in a related directory, somewhere in the project directory tree.

well in most of the DOS/Windows C/C++ compilers predefined header files are stored in INCLUDE directory of the folder containing the compiler

What is abstract data type in c plus plus?

Abstract data types are the opposite of a concrete data types. An abstract data type is one that does not contain all of the function code necessary to create an instance of the object. This design allows subclasses to implement the abstract functions while inheriting the non-abstract functions of the class. A pointer to an abstract instance can call all the abstract functions of that object, which will defer their execution to the actual concrete data type's implementation of that function. As a simple example, an abstract class ChessPiece might have a function called move(). A Pawn subclass would behave differently than a Queen would, but both could be called by outside code without knowing (or caring) about what type of ChessPiece is moving.

Correction

Abstract classes can provide a full and complete (if generic) implementation for all of their pure-virtual functions. It is not the lack of a complete implementation that renders them abstract, but the fact the methods were declared pure-virtual and therefore cannot be inherited. However, derived classes can still call those implementations from within their own implementations.

Furthermore, derived classes that do not provide implementations for all the pure-virtual methods become abstract base classes themselves. But the pure-virtual methods that they do implement can then be inherited through multi-level inheritance.

Non-inheritance of pure-virtual methods only applies to the class that initially declared the method as pure-virtual. Provided an implementation is declared protected or public within a derived class, that implementation can then be inherited by a concrete class, or it can be overridden if required.

What data type will you use to declare a variable to store population on earth?

Since the population of the Earth is around 7 billion (short scale), I would use either a long long integer that was 64 bits in length (if available) that would give me 18 digits of precision, or a double precision floating type that would give me 15 digits of precision.

Why c plus plus compiler cannot produce byte code?

Byte code would be detrimental to performance because byte code must run in a virtual machine. Java compiles to byte code suitable for the Java Virtual Machine (JVM), but C++ compiles to native machine code. For that reason alone, C++ programs perform many times better than equivalent Java programs. However, the need for a virtual machine also means Java is highly-abstract, with no direct access to specific architecture features. C++ has no such limitations and can therefore produce highly-efficient code specific to any platform. Java simply cannot compete for performance, but Java programs need only be compiled once to run on any platform that supports the JVM, whereas C++ must be compiled separately for each platform, and preprocessor directive code must be written to suit each supported platform. This naturally requires a lot more work on the part of the programmer, but the performance speaks for itself.

How do you enable scroll bar in c language in normal environment?

Platform-dependent, GUI is not part of the standard C libraries.

Why linked list is called as linear data structure?

Lookup time for an element in a link list is equal to number of elements in list. Hence linear, like a linear equation: t = n. Compare that to lookup in a tree which is logarithmic: t = log2 n.

What is the difference between datatypes and modifiers in c language?

For example 'int' is a data-type, 'short', 'long', 'signed' and 'unsigned' are modifiers, 'extern', 'auto', 'static', 'register' are storage-classes.

The declarations go like this:

storage-class modifiers data-type identifier

example:

static unsigned short int x;

How to Write a C function which accepts two integer parameters a and b and returns the larger of the two?

This smells like homework, so I'll only give you pseudo-code:

decimal returnLargest(decimal a, decimal b)

is a > b ? then, return a, else, return b;

Why c and java arrays are start with zero and pascal arrays are start with one?

It's a difference in mentality; some believe 0 is the begin, and is thus the only logical choice, and some think the opposite.

How do you determine how fast you enter data for example I type 50 wpm is there an acronym or abbreviation for how fast your data entry skills are?

It depends on whether the data entry is predominantly alphanumeric or numeric. Alphanumeric entry is measured in WPM (words-per-minute) and usually requires a minimum of 60 to 80 WPM however a top-flight secretary can easily exceed 100 WPM. Numeric entry is measured in KPH (keystrokes-per-hour) and usually requires a minimum of around 8,000 to 9,000 KPH. Hardcore data entry requires a minimum of 10,000 KPH while a top-flight number cruncher can easily exceed 12,000 KPH.

First argument of fwrite function is typecast to?

void *

wlen= fwrite ((void *)&data, 1, sizeof (data), file);

if (wlen != sizeof (data)) ... error ...

How can you read and write to files in C programming language?

We can read and write to files with the help of file commands in c programming.There are so many commands related to file for read,write,append,delete etc.

How can you compare precedence of operators in programming of conversion of infix to postfix?

Each operator has a certain precedence level, usually some numeric value. As you parse the expression, you compare the precedence of each operator with the precedence of the last operator, and you either generate code or you push the operator and its operand(s) on two stacks.

What is the average number of nodes accessed in searching for a particular element in an unordered list?

You might be lucky and find the element in the first node, but equally you might be unlucky and not find it until the last element.

The average case is that it takes half the number of nodes in the list.

How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function

int* function(int, int);

or

int* (function)(int, int);

// declare a pointer to a function

int* (*pointer_to_function)(int, int);

Can you write a program in DBMS like C?

DBMS means Data Base Management System, it is not a programming language.

What is ascii value of smily face?

There is no ASCII value of :-)

ASCII encodes only single characters, assigning a numerical 0-127 value to each character.

However, if you want the ASCII encoding of a smiley, here's some samples (using Hex values):

:-) 0x3A2D29

:) 0x3A29

Why are local variable stored on stack?

Because they are created and destroyed on 'last-in-first-out' principle.

What is preorder in tree in c?

There is no such thing. You can traverse a binary tree in pre-order though: first the root, then the left sub-tree, finally the right sub-tree.

What is the fullform of BGI?

The Borland Graphics Interface, also known as BGI, is a graphics library bundled with several Borland compilers for the DOS operating systems since 1987.