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 list morphographs?

You can make a list of them.. of course!

How can a pointer create a perfect copy of a variable?

In order to copy a variable you must copy its value and store that value in another variable, thus creating an independent copy of the value. That is, after the copy, changing one value has no effect upon the other:

void f (int x) {

int x = y;

assert (x == y); // assert the values are the same

assert (&x != &y); // assert the variables occupy different addresses (independent variables)

}

To achieve the same thing with a pointer you must create an independent variable to store the copied value:

void g (int x) {

int* p = malloc (sizeof (int)); // allocate memory to hold the value

*p = x; // copy the value to the allocated memory

assert (*p == x); // assert the values are the same

assert (p != &x); // assert the variables occupy different addresses (independent variables)

// ...

free (p); // release the allocated memory

}

Note that the variable referred to by p is anonymous (has no name). To refer to the value we must dereference the pointer (*p).

Copying a value via a pointer is achieved similarly:

void h (int* p) { int x = *p; // copy the value referred to by p

assert (x == *p); // assert the values are the same

assert (&x != p); // assert the variables occupy different addresses (independent variables)

}

void i (int* p) {

int* p2 = malloc (sizeof (int)); // allocate memory to hold the value

*p2 = *p; // copy the value to the allocated memory

assert (*p2 == *p); // assert the values are the same

assert (p2 != p); // assert the variables occupy different addresses (independent variables)

// ...

free (p2); // release the allocated memory

}

What is a comparative operator?

Comparative operators are used to compare the logical value of one object with another and thus establish the rank (ordering) of those objects.

There are six comparative operators in total:

p<q : evaluates true when p is less than q

p>q : evaluates true when p is greater than q

p<=q : evaluates true when p is less than or equal to q

p>=q : evaluates true when p is greater than or equal to q

p!=q : evaluates true when p is not equal to q

p==q : evaluates true when p is equal to q

How does one declare a string of 49 letters?

char str[50];

Note that you must include the null-terminator, thus you need 50 characters to store a string of 49 letters.

Alternatively, you can use dynamic allocation:

char* p;

p = malloc (50 * sizeof(char));

/* ... */

free (p);

What is an RF loop?

An RF loop, or radio frequency loop, is a type of antenna design characterized by its circular or looped shape, which is used to receive or transmit radio frequency signals. It is often employed in applications such as RFID systems, wireless communication, and certain types of sensors. The loop's geometry allows for improved efficiency and selective reception of specific frequencies, making it effective in various RF applications. Additionally, RF loops can be compact and easily integrated into different devices.

What is the function of sleep?

== == See the Related Links for "Sleep" to the bottom for the answer.

What is the difference between the structure tag and structure variable?

The structure tag is a type. The structure variable is an instance of that type.

What are benefits of havng different data types in pascal programming can you please give me some examples like what are the benefits of having a integer data type real string character etc?

A string allows you to manipulate texts. For example, you might ask the user to type his name, then greet him "Hello, John Doe" (or whatever he typed in). Or you might keep track of names of players, in a computer game.

An example of where a single character might be used is to accept an option from the user - just let him type "y" for yes, or "n" for no.

Numbers are used in all sorts of calculations. Real numbers allow decimals.

While real numbers by themselves might, in theory, seem to satisfy all needs, special types for integers are also used for the following advantages: greater speed, less storage space, greater precision (with real numbers, small errors can accumulate, due to the translation between binary and decimal).

A string allows you to manipulate texts. For example, you might ask the user to type his name, then greet him "Hello, John Doe" (or whatever he typed in). Or you might keep track of names of players, in a computer game.

An example of where a single character might be used is to accept an option from the user - just let him type "y" for yes, or "n" for no.

Numbers are used in all sorts of calculations. Real numbers allow decimals.

While real numbers by themselves might, in theory, seem to satisfy all needs, special types for integers are also used for the following advantages: greater speed, less storage space, greater precision (with real numbers, small errors can accumulate, due to the translation between binary and decimal).

A string allows you to manipulate texts. For example, you might ask the user to type his name, then greet him "Hello, John Doe" (or whatever he typed in). Or you might keep track of names of players, in a computer game.

An example of where a single character might be used is to accept an option from the user - just let him type "y" for yes, or "n" for no.

Numbers are used in all sorts of calculations. Real numbers allow decimals.

While real numbers by themselves might, in theory, seem to satisfy all needs, special types for integers are also used for the following advantages: greater speed, less storage space, greater precision (with real numbers, small errors can accumulate, due to the translation between binary and decimal).

A string allows you to manipulate texts. For example, you might ask the user to type his name, then greet him "Hello, John Doe" (or whatever he typed in). Or you might keep track of names of players, in a computer game.

An example of where a single character might be used is to accept an option from the user - just let him type "y" for yes, or "n" for no.

Numbers are used in all sorts of calculations. Real numbers allow decimals.

While real numbers by themselves might, in theory, seem to satisfy all needs, special types for integers are also used for the following advantages: greater speed, less storage space, greater precision (with real numbers, small errors can accumulate, due to the translation between binary and decimal).

How C code for subtract two parameters?

#include

using std::cin;
using std::cout;
using std::endl;

int main()
{
double firstNumber(0);
cout << endl << "Enter first number: ";
cin >> firstNumber;

double secondNumber(0);
cout << endl << "Enter second number: ";
cin >> secondNumber;

cout << endl << firstNumber << " - " << secondNumber
<< " = " << (firstNumber - secondNumber) << endl;

system("PAUSE");
return 0;
}

Can you use header files on the bottem of the program?

You can use header files (more specifically "include" files) anywhere in a program. You just have to consider what type of statements, declarative or definitive, there are in the include file, and what your effective scope is. That is why they are generally at the top.

How you abbreviate operator?

For example, instead of ++ you can use ++

What is c out?

most basicaly if I tell, cout is the printing statement in c++.

cout<<"Hello world";

The above statement will print the sentence "hello wold".

with the expression cout <<variable, the contents of variable is printed to the standard output.

int variable=10;

cout<<variable;

The o/p will be 10.....

Hope this will help u.... :)

What does the IT structure beneath a structure include?

The IT structure beneath a structure includes software programs. These are also known as computer programs which are non-tangible components of computer that represent sets of programs that govern the operation of a computer system and make the hardware run.

Check whether two values or equal or not without using if?

// prob not what you are looking for since it just eliminates the if statement but

// is still using a boolean operator

bool areEqual = (value1 0);

You might want to clarify the question. Can you use boolean operators? I don't know how you can get around that.

Write a C program using dynamic memory allocation to find the sum of elements of a matrix?

Did you know that memory allocation is not needed to display the matrix? However, the C program is to find the sum of all the elements.