Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Programming 2 – ACTIVITY#2

NAME Inday, Rey Adrian R. Yr. & Sec. BSIT 1 - 2 DATE: April 25, 2021

A. Assume that the address of variable b = fffa

#include<conio.h>
#include<stdio.h> *pb = 25 + 25 50
a = 50 + 10 60
void main() pa = pb;
{ int a, b=25; *pa = 60 + 50 110
int *pa, *pb = 25;
// clrscr(); OUTPUT:
*pb = b + 25;
a = *pb + 10;
pa = pb;
*pa = a + b;
printf(“\n%d %d %d”, *pa, *pb, b);
printf(“\n \n %x %x %x”, pa, pb, &b);
getch();
}

B.
int CCMIT( int r, int s, int t ) m=9
{ int u ; j = 26
u = r + s – t;
k = 17
return u; }

int BSCS( int o, int p) BSIT


{ int q; a = 35
q = ( 1 + p ) – ( o + 1 ); b = 61
return q; } c = 26

void MSIT( int x, int y, int z) BSCS


{ int a, b, c; q = 26
int c = 0;
a = ( 1 + y ) – ( x – 1 ); MSIT
b = a + z; a = 11
c = ( b – 1) – ( a – 1 ); b = 72
printf( “\n %d %d %d”, a, b, c); c = 61

void BSIT( int a, int b ) BSCS


{ int c ; q = 17
a = a + b; b= b + a;
c = BSCS( a, b );
CCMIT
printf( “\n %d %d %d”, a, b, c);
MSIT( c, a, b); } m = 85
j = 70
void main() k = 5950
{ int f, m=9, j = m + 17, k = j – m; f = -5795
clrscr();
BSIT( m, j ); OUTPUT:
k = BSCS( m, j);
m = k * 5;
j = (1 + m ) – ( k – 1);
k = j * m;
f = CCMIT( m, j, k);
printf( “\n %3d %3d %3d %3d \n”, m, j, k,
f);
getch(); }
C.
int *pa,*pb,a = 25,b=35;
pb=&a;
*pb= b + 100;
b = *pb + 10;
pa = pb;
*pa = a + b;

Suppose each integer occupies 2 bytes of memory. If the the value assigned to a
begins at hexa address FICA8 and the value assigned to b begins at hexa address
CAFE6, then

a. what value is represented by &a? FICA8


b. what value is represented by &b? CAFE6
c. what value is assigned to pb? FICA8
d. what value is assigned to *pb? 280
e. what value is assigned to a? 280
f. what value is represented by pa? FICA8
g. what final value is assigned to *pa? 280
h. what value is represented by (pa + 4)? FICB0
i. what value is represented by the expression (*pa + 4)? 284
j. what value is represented by the expression *(pa + 4)? Value of variable 8 bytes
after pa

D. C program contains the following declarations:

int x[8] = { 10, 20, 30, 40, 50, 60,70, 80};

a. What is the meaning of x? One-dimensional array with 8 elements


b. What is the meaning of (x +2)? Address of x[2]
c. What is the value of *x? 10
d. What is the value of (*x + 2)? 12
e. What is the value of *(x + 2)? 30

You might also like