Question

1. Write a complete program that outputs two random numbers on two different lines. Ensure that...

1. Write a complete program that outputs two random numbers on two different lines. Ensure that the program gives a different result on every run.

note: please use c++

Homework Answers

Answer #1

Code

#include<stdlib.h>

#include<time.h>

#include<iostream>

using namespace std;

//main driver code of the program

int main(){

//seed the ranodm number geneartor on every run

srand(time(NULL));

//print the random numbers using rand() method

cout<<rand()<<"\n"<<rand()<<"\n";

}


Screenshot

Output

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a Node.js program that outputs a random square to the console up to 10. basically,...
Write a Node.js program that outputs a random square to the console up to 10. basically, create a quick function to get a random number and then display a asterisk length and width of that random number I use my terminal to run the javascript file For example, if the random number is 6, then the output would be a 6x6 box of " * ": * * * * * * * * * * * * * *...
1. Write a complete program in C++ that does the following: [2] asks a user to...
1. Write a complete program in C++ that does the following: [2] asks a user to enter two integer numbers (display a warning message that the second number should be different from zero) [3] reads the two numbers from the keyboard; [4] displays the product, the sum, the quotient and the remainder of integer division of the first one by the second one. [3] displays the result of floating-point division. Make sure to follow programming style guidelines.
1- Write a program to print only the even numbers from 100 to 200 2- Write...
1- Write a program to print only the even numbers from 100 to 200 2- Write a program to print the odd numbers from 22 – 99 3- Write a program to calculate howe many even number from 10 to 120 1- Write a program to find only the even numbers for 12 different numbers 2- Write a program to find the odd numbers for 10 different numbers 3- Write a program to calculate howe many even number and how...
Write a C++ program that simulates flipping a coin (random numbers) 1000 times and displays the...
Write a C++ program that simulates flipping a coin (random numbers) 1000 times and displays the number of heads and tails. Note that there is no input to the program and the number of heads and tails will be around 500.
write an AVR C program code to create 5 inputs with corresponding 5 different outputs. The...
write an AVR C program code to create 5 inputs with corresponding 5 different outputs. The instruction is listed to follow.  Specify your 5 inputs and 5 outputs. Describe your method .The Conditions: ? AVR C code must be used , Any conditional statement must be used (e.g. IF statement or CASE statement) at least one time, must use the time delay for your output and Bit-wise logic and shift operator.
Using for loops: - write a Java program that adds numbers between 1 to 100 and...
Using for loops: - write a Java program that adds numbers between 1 to 100 and prints the result. - write a Java program that adds odd numbers between 1 to 100 and prints the result - write a Java program that averages even numbers between 5 to 30 and prints the result
Write a NASM program that does the following: 1) Asks the user to enter three numbers...
Write a NASM program that does the following: 1) Asks the user to enter three numbers (each is a byte) A,B, and C 2) Adds up the numbers and stores the sum in variable D 3) Outputs the sum
Write a complete Java program to solve the following problem. Read two positive integers from the...
Write a complete Java program to solve the following problem. Read two positive integers from the user and print all the multiple of five in between them. You can assume the second number is bigger than the first. For example if the first number is 1 and the second number is 10, then your program should output 5 10 Note: There is a white space in between the numbers. Java programming please answer ASAP before 2:30
Step 1: Write a Java program that finds the sum of 10 numbers entered by the...
Step 1: Write a Java program that finds the sum of 10 numbers entered by the user. Step 2: Modify the previous program so that it asks the user how many numbers they have, inputs that many numbers, and finally outputs the average of their numbers. The messages to the user should be clear throughout.
Python code Write a complete program with for loop which calculates the sum of the numbers...
Python code Write a complete program with for loop which calculates the sum of the numbers from 1 to 100
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT