Small code have missing part, computer programming, Programming Languages

Assignment Help:
#question.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Description:
* *
* Written by *** *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include
#include
#include

#define SIZE 10
#define BOUND (SIZE * SIZE)

int main(int argc, char **argv) {
/* We run the program with one number as command line argument and use it as a seed
* for the random number generator. */
srand(strtoul(argv[1], NULL, 10));
int data[SIZE];
/* We randomly generate 10 numbers in the range [0, 100) and store them in data. */
for (int i = 0; i < SIZE; ++i)
data[i] = rand() % BOUND;
int nb_of_odd_numbers = 0;
int nb_of_numbers_at_least_equal_to_50 = 0;
int min = BOUND - 1;
int max = 0;
int gap = 0;
int inversions = 0;


/***********Missing code here************/

for (int i = 0; i < SIZE; ++i)
printf("%4d", data[i]);
printf("\n contains ");
nb_of_odd_numbers > 1 ?
printf("%d odd numbers,\n contains ", nb_of_odd_numbers) :
nb_of_odd_numbers ?
printf("1 odd number only,\n contains ") :
printf("no odd number at all,\n contains ");
nb_of_numbers_at_least_equal_to_50 > 1 ?
printf("%d numbers at least equal to 50, and\n ", nb_of_numbers_at_least_equal_to_50) :
nb_of_numbers_at_least_equal_to_50 ?
printf("1 number at least equal to 50 only, and\n ") :
printf("no number at least equal to 50 at all, and\n ");
printf("has %d as minimal value and %d as maximal value.\n", min, max);
printf("The maximal gap between two successive numbers is %d.\n", gap);
printf("There are %d occurrences of pairs of numbers (x, y) with x > y.\n", inversions);
return EXIT_SUCCESS;
}
-----------------------------------------------------------------------------------
the output should looke something like this:


Sample outputs
$ a.out 0
30 91 15 72 61 41 10 37 98 41
contains 6 odd numbers,
contains 4 numbers at least equal to 50, and
has 10 as minimal value and 98 as maximal value.
The maximal gap between two successive numbers is 76.
There are 22 occurrences of pairs of numbers (x, y) with x > y.
$ a.out 1
7 49 73 58 30 72 44 78 23 9
contains 5 odd numbers,
contains 4 numbers at least equal to 50, and
has 7 as minimal value and 78 as maximal value.
The maximal gap between two successive numbers is 55.
There are 24 occurrences of pairs of numbers (x, y) with x > y.
$ a.out 2
14 98 99 16 13 44 88 9 99 71
contains 5 odd numbers,
contains 5 numbers at least equal to 50, and
has 9 as minimal value and 99 as maximal value.
The maximal gap between two successive numbers is 90.
There are 21 occurrences of pairs of numbers (x, y) with x > y.
$ a.out 3
21 47 25 27 43 16 32 40 75 33
contains 7 odd numbers,
contains 1 number at least equal to 50 only, and
has 16 as minimal value and 75 as maximal value.
The maximal gap between two successive numbers is 42.
There are 16 occurrences of pairs of numbers (x, y) with x > y.

Related Discussions:- Small code have missing part, computer programming

Genetic diseases, Genetic Diseases Problem Description Many human di...

Genetic Diseases Problem Description Many human diseases could be controlled by the knowledge of the gene's structure and pattern. The human gene could be represented by fou

Add external style sheet in html code, On a single XHTML page, include the ...

On a single XHTML page, include the following two div container elements in the body. Using an external stylesheet, add style to the div elements such that one div has some overlap

Matlab, I need to write code to compute matrix multiplication without usin...

I need to write code to compute matrix multiplication without using built in function.

Get horizontal motion field from block matching algorithm, how to get horiz...

how to get horizontal motion vectors field with quiver ?

Database, How to create an ER diagram?

How to create an ER diagram?

No Linux Audible, Why no Audible support for Linux? Maybe they should use a...

Why no Audible support for Linux? Maybe they should use a browser interface?

Matlab project - beginners level, Can you provide help in solving error pro...

Can you provide help in solving error problems, with my matlab project?

Design a system for an online bookshop, As an XML expert you are required t...

As an XML expert you are required to model a system for an online bookshop. After an interview with the shop manager you have the following information: The detail of th

Python 2.7.3, I have assignment about python language . Could you helpe me ...

I have assignment about python language . Could you helpe me to built it

Transform to xhtml, While working in the eHealth Applied Research lab at Mo...

While working in the eHealth Applied Research lab at Mohawk College, you are asked to transform an xml file into an XHTML representationusing XSLT for display in a browser.The xml

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