Login

Create Account
+14156709189
info@expertsmind.com
Submit Homework/Assignment
Get quote & make Payment
Get Solution
Small code have missing part, computer programming, Programming Languages
#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.
Posted Date: 3/10/2012 10:57:10 PM  Location : United States
Ask an Expert
Related Discussions:
Small code have missing part, computer programming, Assignment Help, Ask Question on Small code have missing part, computer programming, Get Answer, Expert's Help, Small code have missing part, computer programming Discussions
Write discussion on Small code have missing part, computer programming
Your posts are moderated
Write your message here..
Related Questions
Computer organisation and architecture, design of parallel adder using 9''s...
design of parallel adder using 9''s compliment
Simulation algorithm, Please remember to read and follow all of the assignm...
Please remember to read and follow all of the assignment guidelines. This assignment will expand upon the simulation algorithm given in class to produce a program which may be u
Explain the various tools for software implementation, Problem 1. What ...
Problem 1. What are the potential advantages of treating two related classes as subclasses of some superclass? 2. Explain the various tools for software implementation 3.
Define the control statements in computer programming, Define the Control s...
Define the Control statements in Computer Programming? The statements are part of the program that performs some action. The compiler will check a program sequentially from the
Php programming help, How to read file in PHP.
How to read file in PHP.
Help with c assignment, You will design and implement a program that will •...
You will design and implement a program that will • analyse the various characteristics of a maze, represented by a particular coding of its basic con stituents into numbers store
Java applet assignment help, Objectives: Create an applet, Use metho...
Objectives: Create an applet, Use methods from the Graphics class , Use the Color class General Instructions: The java class that need to be imported into this assignm
assembly lang. H.W, 1 Allocate array with 32bit 100 element 2 Prompt the...
1 Allocate array with 32bit 100 element 2 Prompt the user to enter the maximum or the upper bound of the random value 3 Read the value and use it generate random numbers to init
Pseudo code for random numbers, Pseudo code the shows logic for a program ...
Pseudo code the shows logic for a program that generates a random number, then ask the user to think of a number between 1 and 10
Non empty string  minimal unique substring, A nonempty string is called a...
A nonempty string is called a minimal unique substring of s if and only if it satisfies: (i) α occurs exactly once in s (uniqueness), (ii) all proper prefixes of occur at le
Assignment Help
Accounting Assignment Help
Economics Assignment Help
Finance Assignment Help
Statistics Assignment Help
Physics Assignment Help
Chemistry Assignment Help
Math Assignment Help
Biology Assignment Help
English Assignment Help
Management Assignment Help
Engineering Assignment Help
Programming Assignment Help
Computer Science Assignment Help
IT Courses and Help
ExpertsMind Services
Online Tutoring
Projects Assistance
Exam Preparation
Coursework Help
Programming Courses
Engineering Courses
Why Us ?
~Experienced Tutors
~24x7 hrs Support
~Plagiarism Free
~Quality of Work
~Time on Delivery
~Privacy of Work