CS410 Visual Programming Assignment 1 Solution Spring 2013

XYZ Technologies is a leading international provider of automated and IT enabled solutions catering to
businesses across various verticals around the globe. Since its inception in 1995, XYZ has regimented itself being
committed to deliver the best software solutions. XYZ has ever since used highly experienced resources in
analysis, development, quality assurance, and implementation to provide a wide range of high-quality consulting
services and cost-effective development of customized application software. XYZ’s worldwide domain and
subject matter expertise, proven track record and the capability to act as solution integrators can give you a truly
cost-effective solution that not only meets, but surpasses your needs.
XYZ –Recruitment For Win32 Programmers
XYZ wants to hire Win32 programmers for its new projects. The basic requirements required for a programmer
are given below:
• Bachelor’s in computer science/software engineering
• Have hands on knowledge of C/C++ language
• Have good knowledge about pointers and its different variations
The following set of questions is made for the applicants who will apply for this job. Now you as an
applicant need to solve the given questions:
A. Consider the following statements
long double i, *ptr;
ptr = &i;
When the above given statements are executed in the RAM 10 bytes of memory will be reserved.
Let’s suppose on each byte some information is stored but what you will do when you want to change only single a byte? Write the syntax to modify the byte no. 4 and 9 i.e. assign 25 to byte no. 4 and 45 to byte no. 9.

Solution A.

assign 25 to byte no. 4


assign 45 to byte no. 9

B. Write the total number of read and write operations against each statement, whereas num is integer array and ptr is integer pointer.
S.No. Statements Read Operation Write Operation
1 **ptr=4;
2 *(num+3);
3 num= 67;
4 ***ptr=100;
5 *(ptr+4)=8;


Read operations           Write Operations

1 **ptr=4;                    2                                   1
2 *(num+3);               0                                      1
3 num= 67;                0                                        1
4 ***ptr=100;             3                                          1
5 *(ptr+4)=8;               ?                                       ?

C. Convert the following array subscripts into indirection format:
i. P[7];
ii. L[4][3];
iii. M[1][2][3];
iv. H[3][i];
v. X[1][4][2][3];


i. P[7];

Answer 1:    *(p+7)
ii. L[4][3];

Answer ii :  *(L+4)[3]  then *(*(L+4) +3)
iii. M[1][2][3];

Answer iii :   *(M+1)[2] [3] then *(*(M+1)+2)[3] then *(*(*(M+1)+2)+3)
iv. H[3][i];

Answer iv :  *(H+3)[i]  then *(*(H+3) +i)

v. X[1][4][2][3];

Answer v : *(X+1) [4][2][3] then *(*(X+1)+4)[2][3] then *(*(*(X+1)+4)+2)[3] then *(*(*(*(X+1)+4)+2)+3)
D. Read the following statements? (Reference: Concern Lecture No. 3 video lecture and slides for
complete understanding of concept).
a. char **array[];
b. char *(*array)();
c. int *func(int);
d. float (*func)(float);
e. char *( *name[20])( char, char);
Lecture Covered: This Assignment covers Lecture No.1 – Lecture No. 4