Login

Create Account
Customer Service Chat
+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
What are program visible and invisible resisters, What are program visible ...
What are program visible and invisible resisters? A4) Program visible is those registers that can be programmed by the users, or which are customizable, whereas Program invisible
Miranda, Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the fo...
Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the following book: http://www.daimi.au.dk/~bra8130/Wiley_book/wiley.html . The book can be downloaded for free from t
Write a perl script that prints the contents of a file, Write a Perl script...
Write a Perl script that prints the contents of a file Write a Perl script that prints the contents of a file, prefixing each line with a line number. The script should acc
Compare 2 strings, Normal 0 false false false ENUS X...
Normal 0 false false false ENUS XNONE XNONE MicrosoftInternetExplorer4
Triple eigenvalue with one eigenvector, Triple Eigenvalue with 1 Eigenvecto...
Triple Eigenvalue with 1 Eigenvector The eigenvalue/vector pair in this case are l and ?h , . Since the eigenvalue is real we know as the first solution we require is, e l
Create hijara game application, Assignment is to create hijara game on any ...
Assignment is to create hijara game on any plate form, you can use any plate form you like or easy to you. For instance let's say you can use visual studio, game studio (Prefer to
Included applications, Hi, Can any of you, tell me how to use Included Ap...
Hi, Can any of you, tell me how to use Included Applications?
Calculate the appropriate weight for each query term, 1Create ir3.py based...
1Create ir3.py based on ir2.py 2Repeatedly prompt the user for a query (if they enter "q", then quit) 3Find the terms in the query, and calculate the appropriate weight fo
Ajax and php, would you like to see some of my code. I am trying to do an a...
would you like to see some of my code. I am trying to do an add friend request. when I view my friends page I click on the add button. with ajax I want the script to send over the
Program for nuclear reactor  embedded systems, Implement the "Nuclear Reac...
Implement the "Nuclear Reactor" example using the following: An ISR triggered by a button press A task to update the temperatures A semaphore to communicate between the ISR and
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