c program, C/C++ Programming

Assignment Help:
Just need the answers to the following 3 questions. "NO NEED to write a program compile or run it, do not need it. Just need the answers for the following questions.

Example question?

Write a hello world program that prints "hello world" twice:

Answer should be in this format:

void_helloworld()
case=1
for ((i=0; i<=case, i++))
{
do
print("hello world");
done
}


Question 1 Floating Point Radix Sort:

Write a C program to sort 32-bit floating point numbers using 8-bit (256 bins) radix sort. Use the variables listed bellow. Floating point numbers require a correctional step after the main loop is completed. Assume lst is initialized with n floating point numbers.

#define N 1048576
#define BIN 256
#define MAXBIT 32
#define LST 1
#define BUF 0
int n, group=8, bin = 256;
int flag; /*to show which one holds numbers: lst or buf*/
float lst [N], buf[N];
int count[BIN], map[BIN], tmap[BIN];

int main (int argc, char ** argv)
{
int i;
flag = LST;
initialize(); /* initilize lst with n random floats */
for( i =0; i < MAXBIT; i=i + group) radix_sort(i); /*move lst to buf to lst depending on the iteration number */
correct(); /*sorted numbers must be in lst */
}
void radix_sort(int idx)
{
int i,j,k,mask; /*initilize mask for lifting the 8 least significant bits. */
int *src_p, *dst_p; /* cast lst and but to int pointers to treat lst/buf as int''s */
/*set src_p and dst_p*/

/*count */

/*map*/

/*move*/
}

void correct()
{
}

__________________________________________________________________

Question 2 -- Splitting a String:

Write a C function that splits a string line separated by commas and stores the values in an array of string fields. The number of commas is unknown and your function must be able to handle any number of commas in the string. Use the following built -in functions: strtok(line, delim); strtok(NULL, delim); malloc(strlen(token)); strcpy(fields[i], token);

/* at the end of this function, fields will have n string store */

void split_line(char ** fields, char *line)
{
int i=0;
char *token, *delim;
........
}

_________________________________________________________

Question 3 Building an array of link list:

Assuming you got split_line() working, complete build_lsts() that builds a list of clips. When building a list, prepend a clip to the list, in other words, add a clip to the front, no the end.

struct clip { int number, int views; char * user; char * id; char * tittle; char * time; struct clip* next;};
struct clip * hourly[MAX_CLIPS];
void build_lsts(char *prefix)
{
FILE *fp; char * cmd, * filename; int i;
for ( i=0; i hourly [i]= NULL;
sprintf(cmd, "ls % s*", prefix); fp = popen(cmd, "r"); i=0;
while (fscanf(fp, "%s", filename) ==1) hourly [i++] = build_a_lst(filename); fclose(fp);
}

/*four steps: open the file, read a line at a time, call split_line() to split the line and store in fields, and call prepend() to insert the clip to the front*/


struct clip *build _a_lst(char *fn)
{
........................

return hp:
}

/*three steps: malloc a clip, set values to clip but set views only! add the clip to the front */

struct clip *prepend (struct clip * hp, char **five)
{
.....

return hp;
}

Thanks.

Related Discussions:- c program

Fraction coding, Create a program that asks the user for two integers which...

Create a program that asks the user for two integers which represent the numerator and denominator parts of fraction. Print out a simplification of the fraction. Example: Enter th

What is a template in c++, Templates permit to create generic functions tha...

Templates permit to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until

Loan negotiation is usually not a straightforward ta, Ask question #Minimum...

Ask question #Minimum 1Loan negotiation is usually not a straightforward task. A type of loan is the discount installment loan. This type of loan has the following characteristics.

C program to allocate memory dynamically for 2-d array, Aim: To implement ...

Aim: To implement a program to allocate memory dynamically for 2 dimensional array (accept and print matrix) using pointers. Code:                       #include #inc

Explain hiding overloaded functions, Hiding overloaded functions We can...

Hiding overloaded functions We cannot overload a base class function by redefining it in a derived class with a dissimilar argument list. Consider examples to see if similar fu

Coding, A palindrome is a string that reads the same from both the ends. Gi...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Differences between a pointer and a reference, Differences between a pointe...

Differences between a pointer and a reference 1.  A reference must always point to some object where as this restriction is not imposed on a pointer. e.g. int *pi = 0;

Define passing structure to a function, Define Passing Structure to a Funct...

Define Passing Structure to a Function? A structure is able to be passed as a function argument identical to any other variable. If we are merely interested in one member of a

Minimumshelf, At a shop of marbles, packs of marbles are prepared. Packets ...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

How do one throw polymorphically?, How do one throw polymorphically?       ...

How do one throw polymorphically?               A: Sometimes people write code such as: class MyExceptionBase { }; class MyExceptionDerived : public MyExceptionBase { };

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd