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 the name for queue insertion and deletion?

The names given to these functions are implementation-specific. Below are some common examples.

Adding an element to the end: enqueue, push, add

Removing an element form the top: dequeue, pop, remove

What is a do-while loop?

A while loop evaluates the conditional expression at the start of each iteration, whereas a do..while loop evaluates the conditional expression at the end of each iteration. Thus the do..while loop always executes at least one iteration.

Write a program in java to print letters of a String in steps?

/* INPUT: Holy Home

* OUTPUT:H

* ------------ o

* --------------l

* ---------------y

* ---------------- _______________//The '-' are spaces

* ------------------H

* --------------------o

* ---------------------m

* -----------------------e

*

*/

import java.io.*;

class StyleString

{

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the String: ");

String s=in.readLine();

for(byte i=0;i<s.length();i++)

{

System.out.println();

for(byte j=0;j<i;j++)

System.out.print(' ');

System.out.print(s.charAt(i));

}

}

}

What does the C statement int open parenthesis asterisk f close parenthesis open parenthesis int asterisk close parenthesis declare?

The declaration int (*f) (int*); declares a function pointer named f. The function pointer can be assigned the address of any function that accepts a pointer to int and returns an int. Function pointers can be used to pass functions to functions. Normally we use typedefs to simplify the notation of function pointers:

typedef int (*f) (int*);

int x (int*);

int y (int*);

f fp; // declare a function pointer of type f

int z = 42;

fp = x; // point to the x function

fp (&z); // invoke function via pointer

fp = y; // point to the y function

fp (&z); // invoke function via pointer.

A typical usage of function pointers is to provide a predicate for a comparison sort algorithm. This makes it possible for the same sorting algorithm to compare objects using different predicates. For example:

typedef bool (*pred) (int, int); // function pointer type named pred

void sort (int a[], size_t len, pred func) {

// simple shell sort

for(int i=len/2; i>0; i=i/2)

{

for(int j=i; j<len; j++)

{

for(k=j-i; k>=0; k=k-i)

{

if( !func (a[k+i], a[k]) // invoke the predicate function

{

swap (a[k], a[k+i]);

}

}

}

}

}

// Declare predicates...

bool less_than (int a, int b) { return a<b);

bool greater_than (int a, int b) { return a>b; }

int main () {

int x[] = {3,5,2,4,1};

sort (x, 5, less_than); // sort array of 5 elements in ascending order

sort (x, 5, greater_than); // sort array of 5 elements in descending order

return 0;

}

Which mechanism can be use to avoid a count-to-infinity loop?

If you are speaking of while loops, this might be the answer for you.

Example 1:

for (i = 0; i < 100; i++)

{

}

Example 2:

do

{

i++;

} while (i < 100);

or even

Example 3:

while (i < 100)

{

i++;

}

This finalization of loops can be done with many conditions. These examples contain only counter. There are many other ways to make an infinite loop finite.

Why goto in c is a bad command?

A 'goto' statement immediately moves the execution of code to another part of the program. This makes the code difficult to follow and to debug. It is better practice to use If-then-else constructs to structure the program code.

What is overriding in c?

Overriding relates to derived classes, where the derived class provides a new implementation for a method declared in the base class. The override is said to be a more-specialised implementation of the base class method, which is itself described as being a generic method. However, the derived class method can still call the base class method, if required.

When the designer of a class can predict that their class will be derived from, they will normally provide virtual methods. These methods are expected to be overridden by the derived class. Overriding a non-virtual method can have side effects if the method is also overloaded. Overriding just one overloaded method will effectively hide all the other overloads in the base class, which may be undesirable.

What is an example of a parameter?

'argc' and 'argv' in this line:

int main (int argc, char **argv)

How do you compute the integral of a function using midpoint rule in C programming?

Please refer to Wikipedia where there is a full C example to do specifically this. I imagine whoever had the homework assignment before you posted their answer there.

How do algorithm to find the factorial of a number?

Factorial (n) = n * Factorial (n-1) for all positive values n given Factorial (1) = Factorial (0) = 1.

Pseudo-code:

Function: factorial, f

Argument: positive number, n

IF n<=1 THEN

RETURN 1

ELSE

RETURN n * f(n-1)

END IF

What is the difference between object oriented and event driven language?

hi, the answer for the above mention question goes like this............

The event driven programming in oops language is very conceptual programig concept, in the event driven program, the user can interact with the user interface by making use of mouse or any other means of controls

'

But in procedural programming , you cannot interact with the user interface through any of the control, u can only and solely interact with the user interface through codes............

so its is rather difficult for the user to interact the user interface through codes

What is quadratic probing in data structure?

Quadratic probing is a scheme in computer programming for resolving collisions in hash tables.

Quadratic probing operates by taking the original hash value and adding successive values of an arbitrary quadratic polynomial to the starting value. This algorithm is used in open-addressed hash tables. Quadratic probing provides good memory caching because it preserves some locality of reference; however, linear probing has greater locality and, thus, better cache performance. Quadratic probing better avoids the clustering problem that can occur with linear probing, although it is not immune.

How do you make a 8 byte integer in C?

Use data-type 'long long' or 'int64_t' (from inttypes.h)

What is the use of complementry operator in c?

The bitwise complement or one's complement operator (~) is used to switch the state of all the bits in a value. Thus 1's become 0, and 0's become 1.

One of its many uses is to unset individual bit(s) in a bitmap. We do this with a bitwise AND of the bitmap and the bitwise complement of the bit(s) we want to unset.

Original bitmap: 01011100

Bit to unset: 00000100 (e.g., bit 2 (bits are zero based from right))

// Using one's complement and bitwise AND

~00000100 & 01011100

11111011 (one's complement of bit 2)

&

01011100 (original bitmap)

=

01011000 (original bitmap with bit 2 unset)

Note that this formula works even if bit 2 were already unset:

11111011 (one's complement of bit 2)

&

01011000 (original bitmap, with bit 2 unset)

=

01011000 (original bitmap unchanged)

What is datatype.Define various types of data types?

In c language data types are used to specify the tye of data.

for ex:

int a;

It means "a" is a variable of type integer.

There are two types of data types in c.They are

  1. primary data types
  2. secondary data types

primary data types are the built in data types and secondary data types are the user defined data types.

eg for primary data types are int,float,char,long,double..

and for secondary are arrays,structures,pointers,unions..

How do you raise a number to a power?

#include <math.h> and link to the math library, then you can use pow(base, exponent).

What is the use of puts in turbo c?

TurboC does have a built-n help: enter puts and press Shift+F1

How is lycra used int film sets?

when they are in the sun .. sun bounces off of them and make it easier to concentrate