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

Program that predicts users age, Program: Write a program that predicts...

Program: Write a program that predicts users' age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an

Input and output routines, Data is required to be fed into the program (inp...

Data is required to be fed into the program (input) and sent out of the program (output). Considering the draughtsman using a CAD station, the input is his commands to cause lines/

Create a minimum of fifteen functions, Purpose For this assignment you ...

Purpose For this assignment you will need to create either a function list or a record series for a CRCRS. Instructions Note: Complete only one of the two assignment op

Advanced input - output routines, Although we can handle most I/O routines ...

Although we can handle most I/O routines with getc and putc , there are file versions of fgets, fputs, fprintf and fscanf . The syntax is       fgets(stringname,n,filename);   Th

Define and explain flow chart with an example, C Programming and Data Struc...

C Programming and Data Structures 1. Define and explain flow chart with an example. 2. Write an algorithm to print all even numbers in descending order and draw the flowcha

I need p2p video streaming, Project Description: P2P media streaming bro...

Project Description: P2P media streaming browser (IE, Chrome, Firefox) plug-in needed that is compatible with Win Xp,7,8 that is Windows Firewall friendly Example like Swarm

How to write program, how to write a program for all the types of beam reac...

how to write a program for all the types of beam reactions

Minimum shelf, 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

Recursion, Given a string, print all possible palindromic partitions using ...

Given a string, print all possible palindromic partitions using recursion

How many levels deep can include files be nested, How many levels deep can ...

How many levels deep can include files be nested? - As such, there is no limit to number of levels of nested include files you can have however your compiler might run out of s

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