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 do the Tellers of Parliament count the number of?

Parliamentary Tellers are MPs or Peers that count the votes during a division (vote) and then announce the result.

What is Arrays of Pointers?

An array of pointers is a contiguous block of memory that contains pointers to other memory locations. They essentially allow non-contiguous memory locations to be treated as if they were an actual array.

What is a sequence of characters?

A sequence of characters is an array of type char, commonly known as a string.

How are three dimensional arrays represented in memory Explain how address of an element is calculated in three dimensional array?

Assuming the array is mapped in contiguous memory, the memory block is divided into equal blocks according to the first dimension, and each of those blocks is divided equally according to the second dimension. The smallest blocks therefore represent a one-dimensional array according to the final dimension.

To look at it another way, a three-dimensional array is a one-dimensional array where every element is a two-dimensional array. And every two-dimensional array is a one-dimensional array where every element is also a one-dimensional array. This concept can also be extended to four-dimensional arrays and beyond (a four-dimensional array being a one-dimensional array where every element is a three-dimensional array).

The address of any element in a contiguous multi-dimensional array is calculated from the type of element in the array and the element index.

If we assume the following three-dimensional array has been declared:

int a[3][4][5];

If we also assume that an int (integer) is a 32-bit value and a byte has 8 bits, then it can be seen there are 3*4*5*32 bits allocated to the array, which is 1920 bits in total or 240 bytes. We can also say that there are 3 arrays of 4*5 integers or, more simply, 3*4 arrays of 5 integers. An array of 5 integers therefore consumes 5*32 bits, which is 160 bits or 20 bytes. The second dimension tells us there are 4 such arrays, which makes 80 bytes, and the third dimension tells us there are 3 of those, which brings us to 240 bytes.

Thus to locate any element, we multiply the last index by 4 (the size of an integer), the middle index by 20 (the size of 5 integers) and the first index by 80 (the size of 20 integers), and add these three results together to obtain the offset from the start of the array. Thus element a[2][3][4] will be found (2*80)+(3*20)+(4*4) bytes from the start of the array, which is 160+60+16 or 236 bytes. This is the address of the last integer in the array, which is fortunate because a[2][3][4] is also the index of the last integer in the array (remember that array indices are zero-based).

The name of the array is also a reference to the start address of the array, thus the start address is a, which is the same as saying the address of element a[0][0][0], which is at offset (0*80)+(0*20)+(0*4), which is obviously 0 bytes from a.

As well as accessing elements by their indices, we can also point at individual elements using pointer arithmetic. Element a[1][2][3] can therefore be found at memory address a+(1*80)+(2*20)+(3*4), which is a+132 bytes. In point of fact, the index notation is simply syntactic sugar for the pointer arithmetic that is actually done behind the scenes.

So much for arrays allocated in contiguous memory. Although there will be few occasions where 240 bytes cannot be allocated easily in contiguous memory, imagine a larger array of integers, say [128][256][512], which is 226 bytes or 64MB. On a 32-bit system, 64MB of contiguous RAM may not be available, so we must split the array into smaller arrays. This is where imagining multi-dimensional arrays as being one-dimensional arrays of one-dimensional arrays comes in handy. If we treat the first two dimensions as a two-dimensional array of integer pointers (each of which is 32-bits), then we only need 128*256*4 bytes, which is only 131,072 bytes or 128kB. Each pointer will reference a separate one-dimensional array of 512 integers, each of which is only 2kB in size (512*4). Although total memory consumption is now 256MB, because the allocation is split into one 128kB allocation and 512 separate 2kB allocations there's a far greater chance the allocation will succeed than if we attempt to allocate 64MB contiguously.

The index notation hasn't actually changed but the underlying pointer arithmetic has. If we assume the pointer array is p[128][256], then referencing p[64][128][256] will return the 257th element of the array pointed to by p[64][128]. This works because the first two dimensions return a pointer to a one-dimensional array of integers. If we suppose that the pointer is x, then the final dimension returns the integer stored at x[256].

The underlying arithmetic is a little cumbersome, but can be broken down as x = (p+(64*(256*4))+(128*4)) + (256*4), which reduces to x = (p+66048) + 1024. Thus the memory address stored at offset 66048 bytes within the pointer array plus the offset 1024 returns the 257th element of the appropriate one-dimensional array of integers.

How do you copy c program to msword?

If you want to copy C source code to a new file in MS Word, use the following steps:

  1. Open the C program in Notepad if it's not already open.
  2. Select all text (usually CTRL+A works fine).
  3. Copy that text to the clipboard (CTRL+C).
  4. Open MS Word (or Wordpad).
  5. CTRL+V to paste the C source code.
  6. Save if desired.

If the C source code is in a file, and you have Windows Explorer open with that file showing, you can open MS Word, and then drag the file from Explorer to MS Word, which will open that file.

Why you need to declare variable 1st in turbo c plus plus?

In C++ all names (including variables) must be declared before they can be used.

Why you use void res in c programming?

since, the word 'void' in C programming language means that it does not return any value to the user or calling function....this is usually used to specify a type of function...... for this reason w use 'void'in c program..

Is it possible to create a program to vote automatically and repeatedly in an on line contest?

Of course. It would be no problem at all for the average college student studying information technology. Of course it would be unethical, but that is your problem.

Write a standard lock plus double check to create a critical section around a variable access?

using System; using System.Text; using System.Threading; namespace thread01 { public class Counter { private int _count=0; private int _even=0; public int Count { get { return _count; } } public int EvenCount { get { return _even; } } private Object theLock = new Object(); public void UpdateCount() { lock (theLock) { _count = _count + 1; if (Count % 2 == 0) // An even number { _even += 1; } } } } class Program { static void Main(string[] args) { Counter count = new Counter(); ParameterizedThreadStart starter = new ParameterizedThreadStart(Program.UpdateCount); Thread[] threads = new Thread[10]; for (int x = 0; x < 10; ++x) { threads[x] = new Thread(starter); threads[x].Start(count); } for (int y = 0; y < 10; ++y) { threads[y].Join(); } Console.WriteLine("Total: {0} - Even: {1}", count.Count,count.EvenCount); Console.ReadKey(); Console.ReadKey(); } static void UpdateCount(object param) { Counter count = (Counter)param; for (int z = 1; z

Who is better active electronically scanned array radar or passive electronically scanned array radar?

Passive Electronically Scanned Array (PESA) and the Active Electronically Scanned Array (AESA) are basically same in technology and principles of operation , both systems are capable of steer its beam Electronically through utilization of Phase Shifter hence it could be made in fully solid state configuration where no moving parts required (like APG-77 Radar on F-22 or Zhuk-AE Radar onboard MiG-35) they're only differs in source of Radio Frequency (RF) source The AESA uses multiple numbers of Radiating Elements where each of them have their own Transmitter and Receiver Module, making the Antenna where those modules located become "active" because it can Radiate by itself While the PESA system uses common RF source that usually found in conventional Radar like Klystrons, Magnetrons and Travelling Wave Tubes (this one especially, most common in Airborne Application like Fighter Radar). In Terms of Advantages the AESA system is typically better than PESA because of following factors : 1.because the Antenna Elements contain its own Transmitter and Receiver modules and located Right behind the Radiator, it would have lower or even No accidental loss , unlike her PESA sister which still require a connection to be made between its RF source to Radiating elements , incidental loss may occur. 2. High fault tolerance, failure of some modules will not hamper the operation of Radar (typical AESA Radar may contain 100++ Elements) however the entire device would fail if the failure occurs in 10% of total module counts.

3.No Single Point Failure , since basically each modules in active Version contains its own transmitter and Receiver modules, the passive device however since it still use single Transmitter device like Traveling Wave tube , failure of the transmitter may hamper the RADAR operations

Answers by :Xenostrike 06 a.k.a Stealthflanker an Illegally Banned member from Electrosphere

EDIT- Bit improvements and adding single point failure in previous answer

Just to help point the above answer at the questions Passive systems have a single point of failure in its transmit devices (Travelling Wave Tubes,Wave Guides, Microstrips and Power Dividers as well as Antenna Feed System) . Active antenna do not have a single point of failure and a meant to degrades performance gracefully except probably malfunctions in its tapering systems or when the beam is steered in very high deflection angle which will reduce antenna effective Area, increase beamwidth hence reducing gain an compromise detection range. Active versions are much more flexible as phase can be varied in each or a groups of Radiating elements to create different waveforms or beamshapes .

Write a c program for Christmas tree?

#include <stdio.h>

main()

{

int i,s,j,m=0;

printf("christmas tree-\n");

for(i=1;i<=8;i++)

{

for(s=i;s<=8;s++)

{

printf(" ");

}

for(j=1;j<=i;j++)

{

printf("* ");

}

printf("\n");

m++;

if(m==3 m==7)

i=1;

}

}

What is the difference between a Chevy C and K pickup?

the c series is rear wheel drive and the k series is 4 wheel drive

What language is Poinsettia?

Poinsettia is from New Latin. It was named after Joel R. Poinsett, an American diplomat, who died in 1851.

How high level computer language works without assembler compiler and interpreter?

I do not know, ask your teacher.

Why, for example Python, PHP, Pearl and JavaScript work without compiler; C, Pascal, Cobol and Fortan work without interpreter.

None work "without assembler compiler and interpreter" so the question cannot be answered as asked because there is no answer.

If we want to write a program without an assembler, compiler or interpreter; it is an easy answer. You hand assemble, that is where you manually enter the machine code. In the early days this was the only way to program a computer. Having done some hand assembly I have to things to say about it.

1) it is not as hard as it might appear to be but it is painfully slow to do.

2) why bother when there are excellent compilers available.

When is linear queue said to be empty?

linear quene said to empty when front==rear==-1

or

front==rear

What are the good qualification of the genunie person?

A genuine, good person believes that God created him or her, and they believe that God is One and has no partners. So they don't say that anyone is like God in anyway. They admit and acknowledge what they are. We are simply creations in need of our Creator every second. There are two kinds of people: Good guys and Bad guys. The genuine person asks God to make him or her one of the good guys. And the good guys do fight the bad guys, but some times in very subtle positively clever ways. aicp

How many numbers between 0-100 are divisible by 7?

Here is a list of whole numbers less than 100 which are evenly divisible by 7

7
14
21
28
35
42
49
56
63
70
77
84
91
98

1. What are three reasons why syntax analyzers are based on grammars?

  1. Simplicity-Techniques for lexical analysis are less complex than those required for syntax analysis, so the lexical-analysis process can be sim- pler if it is separate. Also, removing the low-level details of lexical analy- sis from the syntax analyzer makes the syntax analyzer both smaller and less complex.

  2. Efficiency-Although it pays to optimize the lexical analyzer, because lexical analysis requires a significant portion of total compilation time, it is not fruitful to optimize the syntax analyzer. Separation facilitates this selective optimization.

  3. Portability-Because the lexical analyzer reads input program files and often includes buffering of that input, it is somewhat platform dependent. However, the syntax analyzer can be platform independent. It is always good to isolate machine-dependent parts of any software system.