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 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

What is tab in c language?

When printing text through a string, \t can be used to produce a horizontal tab. The same can also be used when parsing input.

Within the C language source code, a tab is considered a white space and ignored outside string constants, provided that it does not break a keyword into two parts.

What secondary type of data is used in econometric models?

Economic forecasting models predominantly use time-series data, where the values of the variables change over time.

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.

What is the syntax and purpose of the switch statement in c plus plus?

The purpose of a switch statement is to execute one of several sections of code, depending on the value of an integral expression.

The syntax of a switch statement can be stated as follows:

switch(expression)

{

case(constant_expression_1): statement

case(constant_expression_2): statement

//..

case(constant_expression_n): statement

[default: statement]

}

The ellipses around the constant expressions are optional and may be omitted.

The switch statement body consists of one or more case labels and an optional default label (the case labels are also optional, but a switch statement would be meaningless without them). The default statement, if present, need not be the final label in a switch statement. Case and default labels may not appear outside of a switch statement, as they are not treated the same as goto labels.

The constant_expression in each case label is converted to the type of the switch expression and is compared with the switch expression for equality. Control is immediately passed to the labelled statement whose constant_expression matches the value of the switch expression.

Once a label gains control, execution proceeds from that point on and is not impeded by any subsequent case or default labels. However, a break statement may be used to interrupt execution at any time, which will transfer control to the statement immediately following the switch statement body. You may also use a return statement to return control to the calling function, or a goto statement. However, note that while a goto label is not the same as a case label, you may use goto labels inside a switch statement if required.

Here's an example demonstrating how code flows through a switch statement:

int x;

switch(x=rand()%10) // x is a random number in the range 0 to 9.

{

case(0): x=42; break;

case(1):

case(2): x=33; break;

case(3): x=100;

default: x=0;

}

If x were 0, then execution passes to case(0) where the value 42 is assigned to x and the switch exits.

If x were 1 or 2, then 33 is assigned to x and the switch exits.

If x were 3, 100 is assigned to x.

In all other cases, 0 is assigned to x.

You will note that when the switch statement ends, x can only ever be 42, 33 or 0. Why not 100? Look again and you will see that case(3) has no break statement (just as case(1) has no break statement). So although 100 is assigned to x in case(3), the default case immediately assigns 0 to x.

This is not a particularly useful switch statement, but it serves to demonstrate how code flows through a switch statement, and how forgetting to put a break statement at the end of a case can cause unexpected errors to creep into your code.

While you could emulate the same results using a series of if, else if and else statements, the benefit of a switch statement is that it will generally simplify the complexity of your code, because there is only one expression to evaluate, rather than a series of boolean expressions. Your compiler will generate machine code just as if you'd used a series of if statements, but the switch statement gives a greater sense of structure to the statement, and gives a greater degree of control over which section(s) of code will execute for any given evaluation. And just as ifs can be nested within other ifs, switch statements can be nested within other switch statements.

Note that all code in a switch statement must be reachable (that is, not bypassed by all execution paths). For instance the following contains both unreachable and undefined code:

switch(x)

{

x=42; //unreachable

case(100):

int y=42;

break;

default:

x=y; // y is undefined

}

The line x=42 cannot be reached because execution must either pass to either the case(100) or the default label. Similarly, the x=y line is invalid because y is defined within the case(100) label, which is not reachable from within the default label due to the break statement.

What to mix with j and b scotch?

NOTHING!! its nasty on its own, so it twice as bad with a mix. plus it ruins what ever u mixed it with. you will nvr drink it again.

How can you write an algorithm for getting autoformic numbers?

Perhaps you mean an automorphic number? Loop through a series of numbers - for example, all numbers from 1 to 10,000 - and check each of the numbers, whether the condition applies. The condition in this case is that if you square the number, the last digits represent the original number.

Why can't I perform arithmetic on a void pointer?

It's by design. You can still do it, with type-cast:

void *p;

p= (void *)((char *)p + 256);

Is GUI better in Java or C plus plus?

Neither Java nor C++ have a GUI as such -- the GUI is not part of the language specification. But comparing the GUIs for an IDE intended for Java with that of an IDE intended for C++ is hardly going to tell you which is better, since they are intended for completely different purposes. You might as well compare the GUI provided with Adobe PaintShop Pro against the GUI for Microsoft Word for all the good it does.

How do you remove record file in linked list by using C?

You need to make the previous record's next pointer point to the record you are removing's next record, and (if it is a doubly linked list) the next record's previous pointer point to the record you are removing's previous record.

If you are keeping track of the head and/or tail of the list, you need to make sure you update them if you have just removed one of them.

How do you write a standard C program to read date of birth andcurrent date and calculate age using stdioh?

I would use vi (or vim) for the actual typing in of the program and man to check up on the arguments to the functions I rarely use. (And [g]cc to compile the program.)

As to the actual program itself it would depend upon the target audience, that is if I was doing it as a program for me or someone else to use complete with mug-traps.

Basically I would use a while() loop to fgets() the birthdate; the current date I would pick up using time() followed by using localtime() to get the current yyyy/mm/dd. A simple calculation would ensue, taking into account any leap year corrections as necessary.

Obviously necessary sanity checking on inputs made (mug-trapping) would be done along with appropriate messages; as would inclusion of the relevant header files.

That should be enough hints to allow you to get it done.

Particularly, think about the use of fgets() as opposed to gets().

Where can you download MFC include files?

In short, you cannot legally download the Microsoft Foundation Classes (MFC) library for free. The only way to obtain it is to purchase a Microsoft Visual C++ product as it is not provided with the free Microsoft Visual C++ Express.

Note that although Borland licenced the MFC library at one time, for use in Borland Turbo C++, they never fully integrated with MFC and eventually dropped it altogether in favour of their proprietary Visual Component Library (VCL) which replaced the Object Windows Library (OWL) that Borland had used prior to licencing MFC. No other C++ product licenced the MFC library.

Note also that the MFC library is simply a wrapper for portions of the Windows API and was originally called Application Framework Extensions, hence the use of the abbreviation AFX rather than MFC throughout the library.

Define objects and show how they act as user defined data type in c plus plus with the help of a programme?

An object is an instance of a class. A class is a data type that combines data and the specific methods that operate upon that data into a self-contained entity.

To prove that objects are user-defined types, consider the following:

class foo

{

};

int main()

{

foo a;

foo b;

foo c = a + b; // ERROR!

}

The reason there is an error is because the plus operator (+) only works with primitive data types (integral, arithmetic and built-in data types). foo is neither an integral, arithmetic nor built-in data type, thus the plus operator is not supported.

However, if you provide a user-defined plus operator overload (foo::operator+) that accepts a constant reference to a foo object, the code will compile. It's up to you, the class designer, to provide the appropriate implementation.

How do you use a bey pointer?

you use them to collect bey points in japan or china they use it with the bey blade metal fusion or fight video game but every where Else they use it in tournaments to win spots, prize, & glory

What are the function of double insulated case?

An electrical appliance which is double insulated does not have an earth wire fitted. The appliance is designed in such a way that the electrical parts can never come into contact with the outer casing of the device. Common double insulated appliances are hair dryers, radios and cassette players.

Can there be multiplle increment exression in increment part of the for loop statement?

Yes, you can have multiple expressions in the increment poart of the for loop statement. Just use the comma, and each expression will be evaluated from left to right.

Why an array is called derived data type?

it contains the similar type of object which derive from the predefined data type

like int,float,char e.t.c

so it is called derived data type.........................

In C plus plus is it possible to instantiate an array without specifying a length?

No. You can declare a dynamic array without specifying a length, but in order to physically instantiate (either by using malloc or by using object-oriented construction) you must provide a length.

What are Weakness of using pointer in c plus plus?

The main weakness is that the onus is primarily upon the programmer to ensure pointers are not misused, that any memory allocated to a pointer is released as soon as that memory is no longer required, and that pointers are nullified when not in use. There is no automatic garbage collection other than when a thread terminates, at which point all consumed memory is returned back to the system, however its never a good idea to rely on this. Programs with a long life-cycle must be specifically written to clean up resources behind themselves as they go, but the same should apply to any program, regardless of how trivial. It costs nothing and failure to do so is not only lazy, the consequences could easily be dire. If the program were part of an autopilot system, for instance, the consequences wouldn't bear thinking about. For this reason alone, C++ programmers are actively encouraged to use references wherever possible (because they are much easier to use and they clean up after themselves automatically), and to only use pointers when it is absolutely necessary.