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
A vertical pole consisting of a circular tube of outer diameter 127 mm and inner diameter 115 mm is loaded by a linearly varying
Anna [14]

Maximum shear stress in the pole is 0.

<u>Explanation:</u>

Given-

Outer diameter = 127 mm

Outer radius,r_{2} = 127/2 = 63.5 mm

Inner diameter = 115 mm

Inner radius, r_{1} = 115/2 = 57.5 mm

Force, q = 0

Maximum shear stress, τmax = ?

 τmax  = \frac{4q}{3\pi } (\frac{r2^2 + r2r1 + r1^2}{r2^4 - r1^4} )

If force, q is 0 then τmax is also equal to 0.

Therefore, maximum shear stress in the pole is 0.

3 0
3 years ago
A team of engineers is designing a new rover to explore the surface of Mars. Which statement describes the clearest criterion fo
stich3 [128]

Answer:

hello im new trying to get points

Explanation:

3 0
3 years ago
What type of engineer makes sure equipment is safe and operational
zvonat [6]

Answer:

mechanical engineer is the best answer

8 0
3 years ago
There are two machines for sale that you are considering purchasing for your sawmill to produce hardwood flooring. You want to f
devlian [24]

Answer:

Machine 2 has a higher process capability index, it would be best considered for purchase.

Explanation:

Process capability index: Cpk= Min [(mean-L spec)/3sd; (U spec-mean)/3sd]

For machine 1, mean= 48mm and L spec= 46 and U spec= 50, Standard deviation sd= 0.7

Cpk= [0.952;0.952]= 0.952

For machine 2, mean= 47 and L spec= 46 and U spec= 50, Standard deviation sd= 0.3

Cpk= [1.111;3.333]= 1.111

It is clearly observed from the calculations above that the Cpk value of machine 2 is higher than that of machine 1.

Since machine 2 has a higher process capability index, it would be best considered for purchase.

4 0
3 years ago
A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor. HERE
Free_Kalibri [48]

Using the knowledge of computational language in python it is possible to write a code that writes a list and defines the arrange.

<h3>Writing code in python:</h3>

<em>def isSorted(lyst):</em>

<em>if len(lyst) >= 0 and len(lyst) < 2:</em>

<em>return True</em>

<em>else:</em>

<em>for i in range(len(lyst)-1):</em>

<em>if lyst[i] > lyst[i+1]:</em>

<em>return False</em>

<em>return True</em>

<em>def main():</em>

<em>lyst = []</em>

<em>print(isSorted(lyst))</em>

<em>lyst = [1]</em>

<em>print(isSorted(lyst))</em>

<em>lyst = list(range(10))</em>

<em>print(isSorted(lyst))</em>

<em>lyst[9] = 3</em>

<em>print(isSorted(lyst))</em>

<em>main()</em>

See more about python at brainly.com/question/18502436

#SPJ1

7 0
2 years ago
Other questions:
  • The following C program asks the user for two input null-terminated strings, each stored in uninitialized 100-byte buffer, and c
    6·1 answer
  • The device whose operation closely matches the way the clamp-on ammeter works is
    8·1 answer
  • Find the equivalent impedance Zeq seen by the source when Vs = 2 cos (5t) v, C = 0.2 F, R = 1 Ω and L = 0.1 H. (Give angles in d
    12·1 answer
  • Calculate the resistance using Voltage and current, again using voltage and power, again using current and power, and again usin
    12·1 answer
  • Which design activity is part of the design for manufacturability (DFM) methodology?
    10·1 answer
  • What is the function rule for the line? f(x)=−32x−2f(x)=−23x−2f(x)=32x−2f(x)=−32x+2A coordinate grid with x and y axis ranging f
    6·1 answer
  • AA
    10·1 answer
  • a metal rod 24mm diameter and 2m long is subjected to an axial pull of 40 kN. If the rod is 0.5mm, then find the stress-induced
    15·1 answer
  • You guys want to talk at seven I am free then
    7·2 answers
  • Steam locomotives with a 4-6-2 wheel arrangement were usually classified as what?.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!