0 ratings0% found this document useful (0 votes) 35 views9 pagesC Programing Assignment 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Assignment =2
Introduction to © Programming
(COM-201
‘Submitted By: -
Name: - Yeerat Dewan
Roll No.: - 2022a2r013
Branch: - Civil Engineering
Semester: - 2”
Submitted To: - Mrs. Sheetal Mahajan
REMARKS/SIGATUREQL. Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively.
‘The memory requirement for variable t, ignoring alignment
struct {
shot [5]:
union {
float y;
long z;
ye
ye
a. 22bytes
b. 18bytes
c. 14bytes
& lObytes
Q2. 17. The most appropriate matching for the following pairs
memalloc (5) m= NULL; 1: using dangling pointers
free(n); n->value=5; 2: using uninitialized pointers
har *p? *p = ‘a’; 3: lost memory
is:
(a) X—1 Y—3 2-2
(b) X-2Y-123
(QX-3Y-2741
(QX-3Y-12.2
Q3. a) Which of the correct output of the following program?
include
void
main)
{
char str[}= {"\O"};
if (printf("%s", str))
printf("\nString is not
empty\n");else
printf{("\nString is empty\n");3/1
) Identify the error in the following structure declaration:
struct
{
int day;
int month;
int year,
} ddate;
date Jdate, Redate;
QA. Data [] is an array that is declared as int Data{10]; and contains the following values:
Data [] = {12,23,34,45,56,67,78,89,90,100};
) Calculate the length of the array.
bv) Write the upper bound and lower bound.
©) Give the memory representation of the array.
d)Ifa data element with value 56 has to be deleted, find its position.
QS. Ina small company there are S salesinen. Each salesman is supposed to sell 3 products.
Write a program using two-dimensional array to print(i) the total sales by each salesman and
i) total sales of each item.oe WA\
~ \ssigmenest = _—_____ 1a aaa
PRG) Davies tad objects afta tybe shed, fact avd 5 (
. ¢ 2bhats _
Gu e
chad «|S;
Union ¢
Hoot +
dong 25 yet
Ave (eo
the “2
ae buf b i tig \ = 4
4 balsa cl) _16 logtia a
Post 918 besten
Cxbbcation’ — Shar amy sfS] eoill tale tegpi lo
i 1
zs ee 4 ee
Gos, WU id a Union ememnadits ablooa ted
a ‘
(4
oC aeilen So total ine wild be 1éy bouton
(10 +8) )
i. «7 oo a“a so” ty)
: Ib .
{OOH sing is mat empty
Nea Sign fy 9,we Nena) Ts eagle a} Ha ating is lo
&S aan Ue fen eee! Ford Mu fowur
c) _Tndes fo] 1 [2
Sw Dato ralal 12 | 23/34 Be sa eR ae B.Topeuac eye
> 2 farina (te ‘ .
My fan feo its jit) — a
-
[fatal Calor!
nf J=0, (298 Dae
a aa ave
4
M Post tote) sobs by enc salsnns
Jor lice idgsitt)
Ee =
a Fee ee I++)’ e 4
AN is = oda CS Z.
>» a =
faut LO Tatal sen by Samat (nid
M tate) sab of each ilins
he danlicos 12% i114) 5
iW Tah) 20, ~~
\ypee Ibs (p20; 328; 341) S\
eee x