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

What is a virtual base class in C plus plus when the different methods in base and derived classes have the same name true or false?

False. A virtual base class is one that is common to two or more derived classes that are themselves base classes, and that may be combined through multiple inheritance. By declaring the common base class to be virtual in its direct derivatives, only one instance of the common base class exists in the multiple-inheritance classes.

How to write a program that ask user to enter numbers until user enter- 0 then find the biggest of entered numbers in C programming using while or do while?

int i, largest=0;do {

scanf ("Enter a number (0 to exit): %d", i);

if (i>largest) largest=i;

} while (i!=0);

printf ("Largest number is: %d\n", largest);

What are various types of advertising and their purposes?

· Types of Advertising If you ask most people what is meant by "type" of advertising, invariably they will respond by defining it in terms of how it is delivered (e.g., television ad, radio ad, etc.). But in marketing, type of advertising refers to the primary "focus" of the message being sent and falls into one of the following four categories: Most advertising spending is directed toward the promotion of a specific good, service or idea, what we have collectively labeled as an organization's product. In most cases the goal of product advertising is to clearly promote a specific product to a targeted audience. Marketers can accomplish this in several ways from a low-key approach that simply provides basic information about a product (informative advertising) to blatant appeals that try to convince customers to purchase a product (persuasive advertising) that may include direct comparisons between the marketer's product and its competitor's offerings (comparative advertising). However, sometimes marketers intentionally produce product advertising where the target audience cannot readily see a connection to a specific product. Marketers of new products may follow this "teaser" approach in advance of a new product introduction to prepare the market for the product. For instance, one week before the launch of a new product a marketer may air a television advertisement proclaiming "After next week the world will never be the same" but do so without any mention of a product or even the company behind the ad. The goal is to create curiosity in the market and interest when the product is launched. Page 7 of 11 Image advertising is undertaken primarily to enhance an organization's perceived importance to a target market. Image advertising does not focus on specific products as much as it presents what an organization has to offer. In these types of ads, if products are mentioned it is within the context of "what we do" rather than a message touting the benefits of a specific product. Image advertising is often used in situations where an organization needs to educate the targeted audience on some issue. For instance, image advertising may be used in situations where a merger has occurred between two companies and the newly formed company has taken on a new name, or if a company has received recent negative publicity and the company wants to let the market know that they are about much more than this one issue. Organizations also use advertising to send a message intended to influence a targeted audience. In most cases there is an underlying benefit sought by an organization when they engage in advocacy advertising. For instance, an organization may take a stand on a political issue which they feel could negatively impact the organization and will target advertisements to voice their position on the issue. Like most areas of marketing, advertising is changing rapidly. Some argue that change has affected advertising more than any other marketing function. The more important trends in advertising include: While many different media outlets are available for communicating with customers, the ability to distinguish between outlets is becoming more difficult due to the convergence of different media types. In advertising convergence, and more appropriately digital convergence, refers to a growing trend for using computer technology to deliver media programming and information. Convergence allows one media outlet to take advantage of features and benefits offered through other media outlets. For instance, in many areas around the world television programming is now delivered digitally via cable, telephone or satellite hookup. This delivery method uses the same principles of information delivery that is used to allow someone to connect the Internet. The convergence of television and Internet opens many potential opportunities for marketers to target customers in ways not available with traditional television advertising. For example, technology may allow ads delivered to one household to be different than ads delivered to a neighbor's television even though both households are watching the same program. But convergence is not limited to just television. Many media outlets are experiencing convergence as can be seen with print publications that now have a strong web presence. The future holds even more convergence opportunities. These include outdoor billboards that alter displays as cars containing geographic positioning systems (GPS) and other recognizable factors (e.g., GPS tied to satellite radio) pass by or direct mail postcards that carry a different message based on data that matches a household's address with television viewing habits.

Who is J B Lully?

He was a famouse composer that composed many different songs. If you wasnt a bio on him go here:

http://www.8notes.com/biographies/lully.asp

Can I find storage bins that stack on top of each other to organize my basement?

A great place to look is a store such as "Bed, Bath, and Beyond." They have a great selection of stacking storage containers. They also sell Space Bags, which can reduce the total amount of stuff you have to store. Using Space Bags plus the Rubbermaid stacking storage containers will keep your items dry and safe even in a damp basement.

How do you write maximum of two numbers in C programming?

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b;

clrscr();

printf("Enter two numbers");

scanf("%d,%d",&a,&b);

if(a>b)

{

printf("%d is greater",a);

}

else

{

printf("%d is greater",b);

}

getch();

}

If you cannot restart your computer when you are following the instruction of the program does it damage the program if you shut down and switch back on?

No, it just needs to "restart" meaning to just make sure everything is running correctly. Restarting is just like turning your CPU on and off.

Write a C program to find the abbreviation of a full name without using string library function?

//C++ program to abbreviate first and middle name

#include

#include void main(void) { char name[40]; char abname[30]; int i,len,m=1,j=0; //puts is used to print string of characters //although cout is equivalent to it but gets //and cout should not be mixed in one program puts("Enter Name: "); //gets is used to take string input with spaces gets(name); //strlen is a built-in function, declared in //the string.h header file //it returns the length of a string len=strlen(name); abname[j++]=name[0]; abname[j++]='.'; abname[j++]=' '; for (i=0;i

What is tilde operator in c and how its work?

In C, the tilde operator (~) is the bitwise NOT operator. It returns the ones-complement of its operand. That is, the individual bits of the input are inverted in the output, such that all 0s becomes 1s and all 1s become 0s.

Note that the bitwise NOT (~) and logical NOT (!) operators are used for entirely different purposes. With logical NOT, the operator evaluates true (the all-ones bit pattern) when the operand is false (the all-zeroes bit pattern), which is exactly the same as the ones-complement used in bitwise NOT. However, if the operand represents anything other than the all-zeroes bit pattern, the output is the all-zeroes bit pattern.

We can compare the two operators by examining what happens to the bits in each operation. Let's use the value 42 (binary 00101010) as the input.

~42 -43

!42 false

Note that the binary value 11010101 represents -42 on a ones-complement system. However, most systems today use twos-complement notation for signed values, thus if we want to negate a value regardless of which notation is utilised by the system we must use the unary minus operator. On a twos-complement system, unary minus is equivalent to adding 1 to the ones-complement representation of the operand. Thus -42 is equivalent to (~42) + 1 = (~00101010) + 00000001 = 11010101 + 00000001 = 11010110 = -42.

How do you convert bases by using c plus plus?

The algorithm to convert from decimal to any other base is the same regardless of the base. Divide the decimal value by the base and take the remainder. This is the least significant digit. Repeatedly divide the result of the previous division by the base to get the next least significant digit, and so on until the result is zero.

Converting from any non-decimal base to any other base is slightly more difficult because C++ only recognises decimal and hexadecimal values (which are obviously converted to and from binary for our convenience). However since we must use character arrays to represent all other bases, the simplest solution is to convert those strings to decimal and then convert to the required base using the previously mentioned algorithm.

The following program provides 2 functions which allow relatively simple conversion from decimal to any base from 2 to 62, and back to decimal again. Note that Dec2Base() returns a null-terminated character array of the exact size required which can then be passed to Bin2Dec() to produce the original decimal value. Between these two functions you can convert from any base to any other base in the range 2 to 62. The test program output is shown at the bottom of the example.

#include <iostream>

// Convert to any base from 2 to 62 inclusive.

const char MAXBASE = 62;

// Note: Higher bases are possible, but we only have 61 symbols

// to play with (0-9, A-Z and a-z). Bases 11 through 36 are not

// case-sensitive (although we will use upper-case here), while

// higher bases use upper-case for the digits 10 through 35 and

// lower-case for the digits 36 through 61.

// Note that negative values use the '-' symbol, even in binary.

// Computers do not. Computers represent the value -1 as being

// 10000000 in 8-bit binary (the most significant bit represents

// the sign). The value -0 does not exist hence the least

// significant bit is zero, not 1 as might be expected. However,

// we humans can use the '-' symbol to differentiate positive

// and negative decimal values, so there's no reason not to

// follow this convention with all bases.

// Convert the given signed decimal value to the given base and

// return the buffer pointed to by the non-zero pointer to pointer.

char * Dec2Base( int dec, char base, char ** buffer )

{

// The pointer-to-pointer MUST be non-zero.

if( !buffer )

return( 0 );

// Point to the actual buffer (may be NULL).

char * p = *buffer;

// Check validity.

if( dec && base > 1 && base <= MAXBASE )

{

// Some variables.

unsigned int size = 1;

int rem = dec;

// Is the value signed?

if( rem < 0 )

{

// Increase the initial size to cater for sign.

++size;

// Convert the value to a positive value.

rem = dec *= -1;

}

// Release the buffer, if required.

if( p )

free( p );

// Calculate the required buffer size.

while( rem /= base )

++size;

// Allocate a null-terminated buffer and zero it.

p = ( char * ) malloc( ++size );

memset( p, 0, size-- );

// Update the output parameter.

if( *buffer != p )

*buffer = p;

// Point to the null terminator.

p += size;

// Start with the least-significant first.

while( dec )

{

// Step back to the correct character.

--p;

// Determine the digit value (remainder of division).

rem = dec % base;

// Determine the symbol.

if( rem < 10 )

*p = '0' + rem;

else if( rem < 36 )

*p = 'A' + rem - 10;

else

*p = 'a' + rem - 36;

// Prepare for next digit.

dec /= base;

}

// Signed value?

if( p != *buffer )

{

--p;

*p = '-';

}

}

// Return the buffer.

return( *buffer = p );

}

int Base2Dec( char * buffer, char base )

{

// Initialise the return value.

int decimal = 0;

// The buffer MUST BE null-terminated!

unsigned int size = strlen( buffer );

// Point to the null-terminator.

char * p = buffer;

p += size;

// The least-significant column is always the units,

// with position value 1.

unsigned int posval = 1;

// Repeat until we reach the most-significant digit.

while( p != buffer )

{

// Step back to the digit.

--p;

// Store the the digit's value

unsigned int val = *p;

// Is it a sign?

if( val == '-' )

// Adjust the result.

decimal *= -1;

// Not a sign, must be a digit.

else

{

// Convert the digit to a decimal value.

if( val > 'a' )

{

val -= 'a';

val += 36;

}

else if( val > 'A' )

{

val -= 'A';

val += 10;

}

else

val -= '0';

// Multiply by the position value.

val *= posval;

// Increment the result.

decimal += val;

// Calculate the next position value.

posval *= base;

}

}

// Success.

return( decimal );

}

// Test program.

int main()

{

// The test value:

int decimal = -54321;

// Initialise a pointer.

char * buffer = 0;

// Compute all bases from 2 through MAXBASE.

char base = 1;

while( ++base <= MAXBASE )

printf( "%d in decimal is %s in base %u\n",

decimal, Dec2Base( decimal, base, &buffer ), base );

// Convert from MAXBASE back to decimal:

printf( "%s in base %d is %d in decimal\n", buffer, MAXBASE, Base2Dec( buffer, MAXBASE ));

// Don't forget to release the buffer!

if( buffer )

free( buffer );

// Success!

return( 0 );

}

Output:

-54321 in decimal is -1101010000110001 in base 2

-54321 in decimal is -2202111220 in base 3

-54321 in decimal is -31100301 in base 4

-54321 in decimal is -3214241 in base 5

-54321 in decimal is -1055253 in base 6

-54321 in decimal is -314241 in base 7

-54321 in decimal is -152061 in base 8

-54321 in decimal is -82456 in base 9

-54321 in decimal is -54321 in base 10

-54321 in decimal is -378A3 in base 11

-54321 in decimal is -27529 in base 12

-54321 in decimal is -1B957 in base 13

-54321 in decimal is -15B21 in base 14

-54321 in decimal is -11166 in base 15

-54321 in decimal is -D431 in base 16

-54321 in decimal is -B0G6 in base 17

-54321 in decimal is -95BF in base 18

-54321 in decimal is -7H90 in base 19

-54321 in decimal is -6FG1 in base 20

-54321 in decimal is -5I3F in base 21

-54321 in decimal is -5253 in base 22

-54321 in decimal is -4AFI in base 23

-54321 in decimal is -3M79 in base 24

-54321 in decimal is -3BML in base 25

-54321 in decimal is -3297 in base 26

-54321 in decimal is -2KDO in base 27

-54321 in decimal is -2D81 in base 28

-54321 in decimal is -26H4 in base 29

-54321 in decimal is -20AL in base 30

-54321 in decimal is -1PG9 in base 31

-54321 in decimal is -1L1H in base 32

-54321 in decimal is -1GT3 in base 33

-54321 in decimal is -1CXN in base 34

-54321 in decimal is -19C1 in base 35

-54321 in decimal is -15WX in base 36

-54321 in decimal is -12P5 in base 37

-54321 in decimal is -bNJ in base 38

-54321 in decimal is -ZRX in base 39

-54321 in decimal is -Xc1 in base 40

-54321 in decimal is -WCb in base 41

-54321 in decimal is -UXF in base 42

-54321 in decimal is -TGC in base 43

-54321 in decimal is -S2P in base 44

-54321 in decimal is -Qb6 in base 45

-54321 in decimal is -PUf in base 46

-54321 in decimal is -ORa in base 47

-54321 in decimal is -NRX in base 48

-54321 in decimal is -MUT in base 49

-54321 in decimal is -LaL in base 50

-54321 in decimal is -Kj6 in base 51

-54321 in decimal is -K4X in base 52

-54321 in decimal is -JHn in base 53

-54321 in decimal is -IXp in base 54

-54321 in decimal is -Hqa in base 55

-54321 in decimal is -HI1 in base 56

-54321 in decimal is -Gf0 in base 57

-54321 in decimal is -G8X in base 58

-54321 in decimal is -FZf in base 59

-54321 in decimal is -F5L in base 60

-54321 in decimal is -EaV in base 61

-54321 in decimal is -E89 in base 62

-E89 in base 62 is -54321 in decimal

What function does an interpreter perform with the instructions in a high level programming language?

All programming languages need to be converted to machine code. Machine code is the native language of the machine; it is the only language understood by the machine. When we write programs in other languages they must be translated into machine code. To achieve that, we need to write a program to perform the translation for us.

For this we can either use an assembler, a compiler or an interpreter, all of which are machine code programs. Assemblers can only be used with assembly languages, which are low-level symbolic languages that translate near 1:1 with the machine code. The machine code can be saved and executed without further translation. However, assembly languages are not portable; each machine architecture has its own specific version of machine code and therefore requires its own specific assemblers to produce it. To port the code to another architecture you essentially have to re-write the entire source code. There are tools (pre-processors) that can help make the task easier but it's by no means a straightforward process.

[The reverse of assembling is disassembling, which converts machine code into a low-level language that is similar to assembly but is known as disassembly. However, since an assembler strips out all variable names and user comments, a disassembler cannot restore the original assembly language code. Indeed it is impossible to restore the original source code no matter what language was used. Disassembly is as good as it gets.]

All high-level languages are either compiled or interpreted or are both compiled and interpreted.

Compiled languages compile the entire source code into machine code, much like assembly language but with a higher level of abstraction between the source and the machine code. As with assembly languages, the machine code can be saved and executed without any further translation. Being more abstract, compiled languages are much easier to port to other architectures than assembly languages. However they must still be compiled separately upon each architecture. The most popular examples of compiled languages are C and C++.

Interpreted languages do not translate the entire source code, they step through the source code one statement at a time, converting each statement to machine code and executing it before moving onto the next statement. This has the advantage over compiled languages in that you do not have to wait for the entire program to compile before executing the program. A compiled language program can take several minutes to compile, whereas an interpreted language can be executed immediately. However, the need to interpret every statement before executing it incurs a performance penalty. With compiled languages, you only pay the cost during compilation; once compiled, you do not need the compiler. Interpreted languages cannot execute without the interpreter, but any machine that has a suitable interpreter can execute the same source code regardless of which machine architecture it was written on. The most popular interpreted language is BASIC since it is the language most programmers learn before moving onto other languages.

Languages that are both compiled and interpreted use a compiler to produce an intermediate source known as byte code. Byte code is not machine code, it still has to be interpreted, however the byte code "statements" are much simpler to interpret than an interpreted language's statements thus it performs much better. Also, unlike compiled languages, the compiled byte code is highly portable. The best example of such a language is Java which compiles to Java byte code suitable for interpretation by the Java virtual machine (JVM). Given that virtually all platforms provide a JVM implementation, it's no surprise that Java is by far the most popular application programming language in use today. However, it's lack of low-level features limits its usefulness in non-application fields such as driver software, operating system kernels and embedded systems software. Its performance and memory consumption also leaves a lot to be desired, however it's ease-of-use makes it a good stepping stone to learning C++.

How do you sort a one-dimensional array with 10 integers into ascending and descending order?

Sorting can be done by taking the first integer value and comparing it by the rest of the elements in the array . The large or small number can be pushed swapped with its large or small (vice versa) as per preference and the array will be sorted out .

  1. void ascending() {
  2. int x = 0;
  3. int temp = 0;
  4. float fUserArray[10] = {0};
  5. for(x=0; x<10; x++) {
  6. printf("\nPlease enter a number: ");
  7. scanf("%f", &fUserArray[x]);
  8. }//end for loop
  9. for(x=0;x<10; x++) {
  10. if(fUserArray[x] > fUserArray[x+1]) {
  11. temp = fUserArray[x];
  12. fUserArray[x] = fUserArray[x+1];
  13. fUserArray[x+1] = temp;
  14. }//end if
  15. }//end for loop
  16. printf("\nYour numbers in ascending order are:");
  17. for(x=0;x<10;x++){
  18. printf("\n%.2f", fUserArray[x]); }//end for
  19. }//End ascending function
  20. /**********************************/
  21. /*Function definition--descending */
  22. void descending() {
  23. int x = 0;
  24. int temp = 0;
  25. float fUserArray[10] = {0};
  26. for(x=0;x<10;x++) {
  27. printf("\nPlease enter a number: ");
  28. scanf("%f", &fUserArray[x]);
  29. }//end for loop
  30. for(x=0;x<10;x++) {
  31. if(fUserArray[x] < fUserArray[x+1]){
  32. temp = fUserArray[x];
  33. fUserArray[x] = fUserArray[x+1];
  34. fUserArray[x+1] = temp;
  35. }//end if
  36. }//End for loop
  37. printf("\nYour numbers in descending order are:");
  38. for(x=0;x<10;x++) {
  39. printf("\n%.2f", fUserArray[x]);
  40. }//end for loop
  41. }//end descending function

What is the code number for code c on forever lost?

In the office room with the computer without keyboard. If you wait just a bit, the screensaver will come on.

And the screensaver is your answer "C : 8008"

Can a passenger jet do a loop the loop?

legally no - safely and ethically no - technically most large passenger jets no though a few might if done very carefully with minimal fuel and no passengers (in otherwords as lightly loaded as possible)

planes are certified for certain flying conditions based on the forces they are designed to withstand - the stronger a plane is built the heavier it has to be - the heavier it is the less payload (cargo and passengers) it can carry - passenger jets need to carry as much payload as possible so are built as light as safety permits which means no sudden or severe forces are allowed or damage will result (such as the Chicago ohare crash quite awhile back where the copilot made several sudden rudder movements that caused the tail section to break off)

a loop requires a fast speed when first entering since the speed drops rapidly as altitude is gained - otherwise the vertical altitude gain would have to be done entirely by the engines and as powerful as the big jet engines are they don't even have the power to hold it still let alone push it up like a rocket - problem is the heavy jets need to be doing a very fast speed, at least 400 to 600 mph to start the loop to have enough speed to finish it - which means any sudden change in vetical speed puts a huge force on the already very heavy wings - going up at a steep rate of climb for a loop at say 500 mph will rip the wings off almost any heavy jet

next problem is descending from the top of the loop where the weight of the plane can cause it to overspeed since the heavies don't have airbrakes and you cant reverse thrust at those conditions without ripping them apart and flaps are too weak for those forces to use as breaks - when a plane reaches its maximum speed it startes vibrating/shaking and would eventually shake itself apart

all this said it may be possible for some of the smaller jets (737 etc) under controlled conditions and a bit of planning to be able to loop - i don't know if its ever been tried but it may be possible - but then the plane would probably not be airwothy anymore due to the stresses it undergoes so its not likely any one will try it with a multimillion dollar commercial aircraft - wonder if anyone wants to risk their personal 737?!

Barrel RollA barrel roll is when the planes flies on one heading and rolls over upside down as if the a/c is rolling inside a barrel. Test Pilot "Tex" Johnson barrel rolled a Boeing 707 airliner.

Link to a video of this event:

http://www.youtube.com/watch?v=Ra_khhzuFlE

During the hi-jacking of a FedEx cargo DC10-30, the flight crew rolled the a/c almost inverted in order to throw the hi-jacker off his feet, while he was fighting one of the crewmembers.

Reference "Hijacked" by Dave Hirschman

Answer #3

Probably at least some of them could. It might not be a classic, circular loop, but with the right entry speed and enough altitude it probably could be done. Of course you'd have to find someone willing to risk a $40M+ airplane (in the case of a 737; more for larger airplanes) on a rather stupid stunt, and also a pilot willing to fly it.

Of course, the airplane manufacturer would probably have a fit over the liability issues . . .

Airshow pilot Bob Hoover used to do such stunts with Aero Commander 500s and Sabreliners; it should be possible with even larger airplanes. YouTube has a video of Bob Hoover looping his unmodified, straight-stock Commander 500--with the engines shut down:

http://www.youtube.com/watch?v=9ZBcapxGHjE

During his routines he never exceeded 2Gs on the airplane, which is well within the certification limits of all transport-category airplanes. Looping an airliner should be possible without damaging the airplane. It's just the thought of what might happen that's kept anyone from actually trying it.

How do you left factor a grammar using c?

#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

#include<process.h>

void main()

{

clrscr();

char *s1,*s2,*o1,*o2,temp1,temp2;

printf("Enter first statement:");

gets(s1);

printf("Enter second statement:");

gets(s2);

if(s1[0]!=s2[0])

{

printf("Sorry");

getch();

exit(0);

}

o1[0]=s1[0];

o1[1]='-';

o1[2]='>';

for(int i=3;s1[i]==s2[i];i++)

o1[i]=s1[i];

temp1=i;

temp2=i;

o1[i++]='Z';

o1[i++]='\0';

o2[0]='Z';

o2[1]='-';

o2[2]='>';

int p=3;

for(int j=temp1;j<strlen(s1);j++)

{ o2[p]=s1[j];

p++;

}

o2[p++]='/';

for(j=temp2;j<strlen(s2);j++)

{

o2[p]=s2[j];

p++;

}

o2[p++]='\0';

puts(o1);

puts(o2);

getch();

}

When might you want the compiler to ignore type differences in an expression?

a compiler cannot "ignore" type differences, it only can silently

"convert" the items into a common data type, before further

processing. Such conversions require rules, how to make different

types compatible

How do you open a C file as an executible file?

In a canonical C compiler, you type "cc (program file name).c (return) and it spits out "a.out", which is an executable. Works with the original Kernighan and Ritchie C compiler.

For C++, use the .cpp extension and "g++" for the compiler:

In a terminal window, on MacOS,

'cc (program name).c (return)'

'g++ (program name).cpp (return)'

produces an executable named "a.out", which can be run.

'-o (some file name . extension) will change the output file name.

How do you include mysql header file in to turbo C to make connection?

Standard C does not provide such a function; it does not even require you to have an internet connection.

How compile c program in editplus give you the steps?

You can use the gross c compiler and the file will just be compiled with no error. Or microsoft C++ Would work too if one's computer runs on windows.

How do you delete a node with two children in binary tree using c?

Use a recursive function.

void delete_node (node* n) {

/* ensure the given pointer is valid */

if (n==NULL) return;

/* recursively delete the left child */

delete_node (n->left);

n->left = NULL;

/* recursively delete the right child */

delete_node (n->right);

n->right = NULL;

/* delete the data (assuming the data is a pointer)*/

free (n->data);

n->data = NULL;

/* finally, delete the node itself */

free (n);

n=NULL;

}

C language arrange 10 numbers in descending orders and find one of them using baniry search method?

Arranging 10 numbers in descending orders using C programming language and finding one of them using binary search method is as below: #include void main () { int i,j,a,n,number[30]; printf ("Enter the value of Nn"); scanf ("%d", &n); printf ("Enter the numbers n"); for (i=0; i