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
Random question, does anyone here use Lego, do not answer unless that is a yes
Sophie [7]

Answer:

yes i have 2 huge bins of it

Explanation:

8 0
3 years ago
Read 2 more answers
Two variables, num_boys and num_girls, hold the number of boys and girls that have registered for an elementary school. The vari
Flauer [41]

Answer:

Using python

num_boys = int(input("Enter number of boys :"))

num_girls = int(input("Enter number of girls :"))

budget = int(input("Enter the number of dollars spent per school year :"))

try:

dollarperstudent = budget/(num_boys+num_girls)

print("Dollar spent per student : "+str(dollarperstudent))#final result

except ZeroDivisionError:

print("unavailable")

3 0
3 years ago
I don't know what is this​
pychu [463]
That means “ if possible then link”
8 0
3 years ago
Two technicians are discussing a vehicle that cranks slowly when the key is turned to the crank position. The positive battery t
Norma-Jean [14]

Answer:

Both are right

Explanation:

3 0
1 year ago
A segment of four-lane freeway (two lanes in each direction) has a 3% upgrade that is 1500 ft long followed by a 1000-ft 4% upgr
Dennis_Churaev [7]

Answer:

The level of service of of compound grade freeway is LOSB.

Explanation:

Find the provided attachments for explanation

3 0
3 years ago
Other questions:
  • What Type of diploma do you need in order To the get into JMU
    12·1 answer
  • Explain the difference in the heat transfer modes of conduction and convection.
    14·1 answer
  • A city emergency management agency and a construction company have formed a public-private partnership. The construction company
    15·1 answer
  • the voltage across a 5mH inductor is 5[1-exp(-0.5t)]V. Calculate the current through the inductor and the energy stored in the i
    6·1 answer
  • Oliver is designing a new children’s slide to increase the speed at which a child can descend. His first design involved steel b
    15·1 answer
  • You filled a balloon that has a volume of 45 cm3 with helium gas. What is the volume of the helium gas?
    13·1 answer
  • An ideal gas is contained in a closed assembly with an initial pressure and temperature of
    14·1 answer
  • 100000000000x1000000000000=?
    14·2 answers
  • If a material is found to be in the tertiary phase of creep, the following procedure should be implemented:
    8·1 answer
  • which of the following statements are true about client-side DNS? (Choose all that apply). a. If an APIPA address is assigned, t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!