1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
madam [21]
3 years ago
13

When a variable is stored in memory, it is associated with an address. To obtain the address of a variable, the & operator c

an be used. For example, &a gets the memory address of variable a. Let's try some examples.
Write a C program addressOfScalar.c by inserting the code below in the main function.

Questions:
1) Run the Cprogram, attach a screenshot of the output in the answer sheet.
2) Attach the source code in the answer sheet
3) Then explain why the address after intvar is incremented by 4 bytes instead of 1 byte.
Engineering
1 answer:
liubo4ka [24]3 years ago
3 0

Answer:

Explanation:

1) C program file addressOfScalar.c

#include <stdio.h>

int main()

{

//intialize a char variable, print its address and the next address

char charvar = 'a';

printf("address of charvar = %p\n", (void *)(&charvar));

printf("address of charvar - 1 = %p\n", (void *)(&charvar - 1));

printf("address of charvar + 1 = %p\n", (void *)(&charvar + 1));

//intialize a int variable, print its address and the next address

int intvar = 1;

printf("address of intvar = %p\n", (void *)(&intvar));

printf("address of intvar - 1 = %p\n", (void *)(&intvar - 1));

printf("address of intvar + 1 = %p\n", (void *)(&intvar + 1));

}

In C programming language, an int variable takes 4 bytes of memory. So any arithmetic on integer address, always considers it as 4 bytes of data. So intvar-1 refers to a location 4 bytes before intvar's address and intvar+1 refers to 4 bytes after intvar's address.

You might be interested in
There is an electric field near the Earth's surface whose magnitude is about 145 V/m . How much energy is stored per cubic meter
weqwewe [10]

Answer:

u_e = 9.3 * 10^-8 J / m^3  ( 2 sig. fig)

Explanation:

Given:

- Electric Field strength near earth's surface E = 145 V / m

- permittivity of free space (electric constant) e_o =  8.854 *10^-12 s^4 A^2 / m^3 kg

Find:

- How much energy is stored per cubic meter in this field?

Solution:

- The solution requires the energy density stored between earth's surface and the source of electric field strength. The formula for charge density is given by:

                                        u_e = 0.5*e_o * E^2

- Plug in the values given:

                                        u_e = 0.5*8.854 *10^-12 *145^2

                                        u_e = 9.30777 * 10^-8  J/m^3

5 0
3 years ago
If there are 16 signal combinations (states) and a baud rate (number of signals/second) of 8000/second, how many bps could I sen
Mice21 [21]

Answer:

32000 bits/seconds

Explanation:

Given that :

there are 16  signal combinations (states) = 2⁴

bits  n = 4

and a baud rate (number of signals/second) = 8000/second

Therefore; the number of bits per seconds can be calculated as follows:

Number of bits per seconds = bits  n × number of signal per seconds

Number of bits per seconds =  4 × 8000/second

Number of bits per seconds = 32000 bits/seconds

6 0
3 years ago
Case Study # 1: Cadbury Crisis Management (Worm Controversy)
Rasek [7]
H is the answer
Step by step
3 0
3 years ago
Responding to the campaign of 4 classes, 7A, 7B, 7C, 7D contributed the amount of support proportional to the numbers 8,6;7;5 kn
Zolol [24]

Writing life on my fantasy planet

8 0
3 years ago
. . . . . . . . . . ..........
Naddika [18.5K]

Answer: Thx for points...

Explanation:

Heres Random Info About Enginnering (because why not): Engineers are involved in all aspects of interactive TV technology, from designing new cables, to creating new film emulsions, to engineering better sound quality. This technology allows viewers to select any program, film, or game from more than 500 channels. Engineers play an instrumental role in the theme park industry?

Hope This Helps Someday!

5 0
3 years ago
Other questions:
  • Practicing new things strains your brain fibers, weakening your ability to make connections.
    13·1 answer
  • Block A has a weight of 8 lb. and block B has a weight of 6 lb. They rest on a surface for which the coefficient of kinetic fric
    8·1 answer
  • What are the two most important things to remember when at the end of your interview?
    6·1 answer
  • The mass flow rate in a 4.0-m wide, 2.0-m deep channel is 4000 kg/s of water. If the velocity distribution in the channel is lin
    5·1 answer
  • The current flow in an NMOS transistor is due to one of the following:
    11·1 answer
  • Steven is starting a project that requires a specialized, experienced contractor. Which selection process is the most suitable f
    11·1 answer
  • True or False; If I was trying to find the Voltage of my computer, and I was given the Watts and Amps it uses, I would use Watt'
    8·1 answer
  • When an output gear is larger than the input gear the greater ratio is greater than 1 T or F​
    9·1 answer
  • Which Finance jobs can someone pursue with only a high school diploma? Check all that apply.
    10·2 answers
  • <img src="https://tex.z-dn.net/?f=%5Cint%5Climits%5Ea_b%20%7B7x%7D%20%5C%2C%20dx" id="TexFormula1" title="\int\limits^a_b {7x} \
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!