Quiz 3: Data Representation

Computing

Program Plan: • Include header files and declare required namespaces. • Initialize the main() function. • Create functions insert_in_linked_list, insert, print.. • Prompt the user to enter index and element. • Display the output. //******************************************************** // This program creates a list of 10 elements and then //inserts // an element at specific index; given by the user. //******************************************************** // import header files in the program #include #include // declare a structure Node typedef struct Node { // members of structure // data to store the numeric values int data; // pointer next to store the address of the next link. struct Node *next; // a global object of struct is created. }node; The insert_in_linked_list function is used to insert the data value passed as argument, after the pointer address passed as argument. // declare function insert_in_linked_list void insert_in_linked_list(int data, node *after_pointer) { // declare local pointer node *pointer; // Allocate memory for the new node and put data in it pointer = (node *)malloc(sizeof(node)); // connect the new node with the continuing list thereafter. pointer- next = after_pointer- next; // put the element in the list pointer- data = data; // connect new node to the list. after_pointer- next = pointer; } The insert function is used to insert an element at the end of the list. The node pointer is traversed to the end of the list and then allocated space for new element to be inserted at the end. // declare function insert; void insert( int data, node *pointer) { // Iterate through the list till we encounter the last node. while(pointer- next!=NULL) { // move pointer to the next node pointer = pointer - next; } // Allocate memory for the new node and put data in it. pointer- next = (node *)malloc(sizeof(node)); // make the new allocated space pointed by the pointer pointer = pointer- next; // put the element in the list pointer- data = data; // assign NULL to the end of the list. pointer- next = NULL; } The recursive function call of print function displays all the elements in the list. // declare function print void print(node *pointer) { // if there is no element in the list if(pointer==NULL) { // return null return; } // display the element in the list printf("%d ",pointer- data); // recursively call function print to display other elements in the list print(pointer- next); } // declare function main int main() { // declare variables int loop,index,eleIns; // declare pointer objects of structure node node *start = NULL, *temp; // allocate memory space to the first node, which is the beginnig of the list start = (node *) malloc (sizeof(node)); // next of start is NULL start- next = NULL; To create a default list, 10 values are inserted in the list, by calling the insert function. // loop to insert 10 elements in the list for(loop = 1; loop = 10; loop++) { // call function insert to put elements insert (loop*10, start); } // display the list printf("\n"); print(start); // display newline printf("\n"); // take input from user printf("Enter index after which you wish to insert a new element : "); scanf("%d", index); // accept the element to be inserted. printf("Enter the element to be inserted : "); scanf("%d", eleIns); If the value of index is three, then in temp store the address of the third element in the list, so that one can pass this address to insert_in_linked_list function for inserting element after this address. // search for the index given by the user temp = start- next; for(loop = 1; loop index; loop++) { // to check if list has elements or not if(temp- next != NULL) { // store the address in pointer temp temp = temp- next; } } // call function insert_in_linked_list and pass the address after which element is to be inserted. insert_in_linked_list(eleIns,temp); // display list with new element inserted. printf("\n"); print(start); } Sample Output: 0 10 20 30 40 50 60 70 80 90 100 Enter index after which you wish to insert a new element : 3 Enter the element to be inserted : 35 0 10 20 30 35 40 50 60 70 80 90 100

Solution: Nowadays, the commonly used microprocessor is Intel Core which supports all the computer system. • Intel Core is a processor where Intel represents its brand name. • These kinds of processor which exists in the market that from the mid-to-high endPentium processors, then the Pentium to the entry level , and the Celeron series of processors to the low end. • Earlier, also named Xeon processors which is identical and the capable versions for the workstations and the server market. The lineup of Core proce ssors that includes are: • 32-bit microarchitecture Core series o Core Duo o Core Solo • 64-bit microarchitecture Core series o Core 2 Solo o Core 2 Duo o Core 2 Quad o Core 2 Extreme • New lineup Core processor series o Core i3 o Core i5 o Core i7 The Data Types that are supported: The data types supported by Intel Core processor can be differentiated under the categories as given below: img Storage Bits: The numbers of bits used by each data type are given below: img Internal representation on each data: The representation of various data types in Intel core is illustrated below: In the processor, each data type represented internally as a string for processing, which converts the string into the machine language. img

Number System The binary representation of decimal number 10 is as follows: A binary number is a 8 bit number which has the base 2, that is, it constitutes 0 or 1. img img The octal representation of decimal number 10 is as follows: An octal number is a number which has the base 8, that is, it constitutes digits 0-7. img The hexadecimal representation of decimal number 10 is as follows: A hexadecimal number is a number which has the base 16, that is, it constitutes digits 0-9 and alphabets A-F. img