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
3. When starting an automatic transmission
Alexxandr [17]

Answer:

It should be in Park or Neutral.

Explanation:

4 0
4 years ago
Maintain a distance of at least
Virty [35]
The answer is c. 4 seconds
8 0
3 years ago
Read 2 more answers
I logged on today to work on my makeup work. <br> A: True<br> B: False
Lelu [443]
True I don’t really know.
7 0
3 years ago
Read 2 more answers
The U.S. Coast Guard requires certain equipment be carried onboard a vessel based on the vessel's length. How must an operator m
nevsk [136]

Answer:

The answer is option B(:

Explanation:

3 0
3 years ago
Select the correct answer.
FrozenT [24]

Answer:

B. Italy

Explanation:

Hope this helps :)

6 0
3 years ago
Read 2 more answers
Other questions:
  • Twenty-five wooden beams were ordered or a construction project. The sample mean and he sample standard deviation were measured
    6·1 answer
  • Pick a subjectarea/field/topic that you are interested in. For each of the following Bonham- Carver uses of GIS give an example
    7·1 answer
  • A natural-draft cooling tower receives 250,000 ft3/min of air at standard atmospheric pressure, 70oF, and 45 percent relative hu
    8·1 answer
  • A rectangular open box, 25 ft by 10 ft in plan and 12 ft deep weighs 40 tons. Sufficient amount of stones is placed in the box a
    13·1 answer
  • The controlled variable in a closed-loop system is the direction of a robot arm. Initially, it is at 50o; then it is commanded t
    12·1 answer
  • A 40kg steel casting (Cp=0.5kJkg-1K-1) at a temperature of 4500C is quenched in 150kg of oil (Cp=2.5kJkg-1K-1) at 250C. If there
    13·1 answer
  • A sample of soil has a volume of 0.45 ft^3 and a weight of 53.3 lb. After being dried inan oven, it has a weight of 45.1 lb. It
    12·1 answer
  • PLS HURRYY!!!<br> Look at the image below
    10·1 answer
  • Reverse Engineering: Structural Analysis
    14·1 answer
  • Engineered lumber should not be used for
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!