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

Flow chart, flow chart for calculating the volume of sphere

flow chart for calculating the volume of sphere

Online tutor, Given an char variable last that has been initialized to a lo...

Given an char variable last that has been initialized to a lowercase letter, write a loop that displays all possible combinations of two letters in the range ''a'' through last. Th

Smuggler, Smugglers are becoming very smart day by day. Now they have devel...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Define character input and output with files, Define Character Input and Ou...

Define Character Input and Output with Files? This is done by using equivalents of putchar and getchar which are called putc and getc. Each one takes an extra argument which id

#otto cycle, To get the efficiency of Otto cycle by C/C++.

To get the efficiency of Otto cycle by C/C++.

Loop statement, write a c++ program to accept 3 numbers and find the larges...

write a c++ program to accept 3 numbers and find the largest of 3 numbers

Define the category of function - computer programming, Define the Category...

Define the Category of Function? A function, depending on whether arguments or parameters are present or not and whether a value returned or not, may belong to one of the foll

Algorithm, algorithm to prepare mark sheet of a student by inputing name,br...

algorithm to prepare mark sheet of a student by inputing name,branchcode,semester,register no,5 marks of students and total mark of student

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