You are on page 1of 8

Assignment 1 Function Calling Make four functions which operate on floating point data.

Each function will take 2 input arguments (by value) and would return the result. Operations which will be implemented includes 1. ddition

2. !ubtraction ". Multiplication #. $ivision $efine these functions and show how these functions will be called.

Assignment 2 Data types + sizeof() + Function Calling + Passing by value %rite a function in which use si&eof() operator to find the intrinsic si&es of all the available data types in '(')). sk from user whether to display the si&e if individual data types or not* Moreover+ sum the si&e of all the data types. Assignment 3 Conditional tatement

Enter your marks and decide grade. Marks can either be taken from user or it can be hard,coded. Assignment ! "nt#oducto#y concept of a##ays and loops -ind si&e of different data types and store them in an array. .hen using /for0 loop+ print this array. Assignment $ Playing %it& A C"" using loop

.ake the user name in small alphabets. Make the first small letter of every word to capital case. $on1t disturb spaces during this conversion. n e2ample is user will enter /3uaid a&am0. 4our program should convert it into /5uaid &am0.

Assignment ' Function Calling + Passing by add#ess %rite a function which takes two arrays of type /short0 and si&e 16 as arguments+ perform dot product of these two arrays and accumulate the sum in an accumulator of type /int0. 7eturn this sum to the calling function by value. Assignment ( )ecto# p#oduct and vecto# dot p#oduct by using pointe#s %rite two functions which takes two arrays of type /short0 and si&e 16 as arguments. 8owever in the called function+ it performs dot product using pointer arithmetic. i. -unction dot9roduct() returns the sum by value. ii. -unction vec9roduct() takes the result array also as an argument and writes the result in it. Assignment * t#ing p#ocessing functions %rite your own string processing functions like my!trcpy()+ my!trlen()+ my!tr'at()+ my!trcmp() using: i. for loop and ii. while loop. Assignment + File ,ead -#ite + t#uctu#e .sage

4ou are given a te2t file (/input-ile.t2t0) with integer numbers. ;t carries two columns like as follows: 1 "1# 2 ""# " "#< # <#< -irst column shows the date in a month and the second column shows the e2penses incurred on that that. -or e2ample+ on the 1 st day of month+ e2pense was "1#(, 7s and similarly on 1=th day of month e2pense was #<>6(, 7s. 4ou are re3uired to do following things: 1. 4ou have to read these columns from the file into a structure which would look as follows:

2. array. ".

typedef struct{ int date; int expense; }ledger; Make an array of this structure and store the values read from file into this dd your registration number to the e2pense field of the structure e.g. if the ;$ of some student is 2"#<+ he will add this ;$ to the e2pense field of the array for all the days. 9rint this updated array into a new file named /output-ile.t2t0.

#.

Assignment 1/ tac0 usage + ope#ations

Assignment 11
P#oblem tatement

4ou are assigned the additional duty of librarianship of the library of ;3ra ?niversity. ll the students who are taking the $ata !tructure in summer were also re3uired to become the member of library.

11 8owever only five students became the member+ who are as follows:
2 1 2 3 ! $ ' ,egist#atio n2 62>< 6126 61"# 6162 61C1 61CC 3ame %a@iha !ana Mir&a Ahurram 8ayat Baig !aad -aran fa3 li Ahan

!aad 8ameed %aliullah

.hese students are given in the attached te2t file /student.t2t0. i1 Make a function list_create().

ii1

;n this function+ read the student name and registration ;$ from the te2t file /student.txt0 one by one. 4ou are re3uired to make a link list of these members. Each node of your link list will be based on following self,referential structure.

iii1 iv1

struct node{ short rid; // registration id char name[32 ; // student name struct node !next; // point to next node }; typedef struct node node; v1 7eturn the head point to the calling function.

21 Make a function list_count(). 4ou will pass the head pointer to this function
and it would return the count of the nodes.

31 One day+ shah g came into action+ he rushed to you (remember you are a
librarian) and said /9lease make me member as well0. 4ou said+ /DentlemanE Fo problem+ @ust tell me your ;$ and full name0. !hah D supply you the following information '22* i1 ii1 yed 3adeem "4bal &a&

'reate a new node to entertain shah g. 4ou are re3uired to write a function list_append(). 4ou will pass the head pointer of the list created above G along with new node. 4our function append the new node at the end of the e2isting linked list.

!1

s the summer progressed+ Mir&a Ahurram got involved in his side business. 8e now hardly finds any time to spend in library. !o he decided to 3uit. i1 %rite a function list_search(). 4ou will pass the head pointer to this function along with the student id. .his function will traverse through the linked list+ and will return the pointer of the node which is previous to the node in which it finds the matching id. %rite a function list_node_remo"e(). 4ou will pass the pointer of the node G the node which is re3uired to be removed. ;n our case+ this pointer has come from the list_search() function.

ii1

$1 -inally Ma@id came out of his hibernation: he wants to be ne2t to %a@iha but
before !aad '23* i. ii. fa3. 8e has supplied the following information for his node. yed 5a6id 7assan 'reate a new node to entertain Ma@id. %rite a function list_insert(). ;nsert the node of Ma@id using this function.

'1 9rint this final linked list on screen as in the final. (1 $ue date for this assignment is 8uly 229 2//+ befo#e 1:// pm

,eading Fo#matted Data f#om File


#include $fstream.h% struct node{ short rid; // registration id char name[32 ; // student name struct node !next; // point to next node }; typedef struct node node; "oid main("oid) { ifstream in_file(&students.txt&); node node[' ; int i ( ); *hile (+in_file.eof() ) { in_file %% node[i .rid; // to read registrtion id as a short integer in_file.ignore(,); // to discard *hite space in_file.getline(node[i .name-32 ); // to read name as a string i..; } }

Assignment 12
1. $esign a 5ueue using array. !i&e of the 3ueue is 16. .he 5ueue should be circular as it was e2plained in the class. -ollowing functions should be made. a1 b1 c1 d1 init() en3ue() de3ue() isEmpty()

e1 is-ull() f1 si&eOf5ue() 2. Our students of data structure class spent the month in updating their profiles on -acebook and watching videos on 4ou.ube. .he result was that the internet bill was 3uite big as compared to previous months. !o their parents have ordered them to pay this bill at the $ bank+ ;3ra ?niversity branch. Hist of the students is in the attached file. a1 4ou have to read this file in a 5ueue. b1 .he problem (for you people) is that the bank still adheres to some principles. .hey have asked the customers to be split into two 3ueues: one is meant for gents and the other for ladies. c1 4ou have to read data from the parent 3ueue and en3ueue it into two 3ueues a) gents+ b) ladies. d1 -inally print these two 3ueue on the screenI.i know you people would love to do it. ". $ue date is 8uly 2*9 2//+ befo#e 1:// pm

Assignment 13
;ina#y ea#c& <#ees %rite routines for Binary .rees that 1. 'ount the number of nodes 2. 'ount the number of calls of inorder(). ". 'ount the number of nodes having a particular value+ say Jb1 #. 9rint out the value of only the leaf nodes

Assignment 1!
1. %rite sorting function using a. Bubble !ort (B!) b. !election !ort (!!) c. ;nsertion !ort (;!)

d. Binary !earch .ree (B!.) 2. Denerate an array of 2> elements of type /int0 at run time using rand() function. !ort this array using the function defined in part 1. ". Denerate an array of 1>> Million elements of type /int0 at run time using rand() function. !ort this array using the function defined in part 1. Moreover calculate time taken by each method using clock() function. #. $ue date is August !9 2//+ befo#e 1:// pm1

You might also like