• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 1 fuera de 4 páginas
Otro

Computer Science 101: Assignment 1 on Random Number Generation and Command Line Parameters

Document preview thumbnail
Vista previa 1 fuera de 4 páginas

Often, computer scientists, statisticians, physicists, social scientists, and mathematicians need a list of random numbers. Political pundits also find lists of random numbers useful to provide 'statistical' evidence of their arguments.

Vista previa del contenido

Computer Science 101: Assignment 1 on Random
Number Generation and Command Line Parameters
Reminders:

 Follow the submission instructions.
 Remember to comment your code!

0) Random number generation. (50 pts)
Often, computer scientists, statisticians, physicists, social scientists, and mathematicians need a
list of random numbers. Political pundits also find lists of random numbers useful to provide
'statistical' evidence of their arguments.

Implement a tool to generate and print a sequence of 10 random numbers. Each random
number should be an integer in the range from
0 to 100, inclusive (that means both 0 and 100 should have a chance of appearing). I do not
expect you to implement your own random number generator. I expect you to use the standard
way of obtaining randomness in a secure fashion.

$ ./grand
56 77 91 2 33 40 72 100 6 2

Augment your program to take a command line parameter specifying how many random
numbers to generate. That is, if grand is invoked by:
$ ./grand 4
it will output 4 random numbers from 0 to 100, inclusive. Make sure your program does
something sensible if the supplied argument is not a valid integer. There should not be an
arbitrarily imposed upper limit to this number (in other words, do not have an artificial cap on
the value of the argument).

Since it is easy to forget how to use programs, it is often useful to provide a well-known
command line switch (or parameter) that tells the user how to invoke the program. Augment
your program to recognize two more command line arguments, '-h' and '--help' that prints out
the usage information for the program. For example,

$ grand -h
and
$ grand --help
should output the following usage information:
grand [-h | --help] : output this usage message.
grand [n] : print out n random integers in [0,100]

Finally, augment your program to print out its version. Don't forget to add this usage case to
your help dialog.

Información del documento

Subido en
4 de julio de 2025
Número de páginas
4
Escrito en
2026/2027
Tipo
Otro
Personaje
Desconocido
Gratis
Descarga

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
LectScotty
4.1
(28)
Vendido
198
Seguidores
6
Artículos
5289
Última venta
20 horas hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes