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
Computer design project , I''m studying electrical engineering, and this se...
I''m studying electrical engineering, and this semester im taking course that called Computer Design. in this course they need me to a final project about any thing we took during
Expression Tree, For this assignment you will read a file expression.txt an...
For this assignment you will read a file expression.txt and create an expression tree. The expression will be a valid infix expression with the all the necessary parentheses so tha
Series solutions  higher order differential equations, The idea of this se...
The idea of this section is not to do anything new along with a series solution problem. Instead this is here to exemplify that moving in a higher order differential equation does
Difference between CMP and SUB, 1. CMP and SUB CMP is used for comparing 2 ...
1. CMP and SUB CMP is used for comparing 2 registers by subtraction them from one another, but answer is not saved, whereas SUB subtracts 2 registers and saves the answer.
Linux shell scripint, Shell scripting linux
Shell scripting linux
Higher order differential equations, We'll start this section off with the ...
We'll start this section off with the material which most text books that will cover in this section. We will take the matter from the Second Order chapter and expand this out to n
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
Write a prolog predicate for a list, Write a Prolog predicate remove_nth(N,...
Write a Prolog predicate remove_nth(N,L1,L2) that is true if list L2 is just list L1 with its Nth element removed. If L1 does not have an Nth element then the predicate should fail
Assignment help, Write your own version of the strcmp function string_compa...
Write your own version of the strcmp function string_compare. Supply a main program that will test each of the 3 differing outcomes. int string_compare(char *s, char *t); retu
Programming assignment, The fancy new French restaurant La Food is very p...
The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of t
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
ExpertsMind Services
Online Tutoring
Projects Assistance
Exam Preparation
Coursework Help
Programming Help
IT Services
Why Us ?
~Experienced Tutors
~24x7 hrs Support
~Plagiarism Free
~Quality of Work
~Time on Delivery
~Privacy of Work