Question

Answer: cout << k/(i+j) Q1) Provide code that outputs a random number 10 through 20? Q2) Provide code that outputs a random c


Q2) Provide code that outputs a random character ‘a through ‘y?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

Source Code:

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int main()
{
   srand(time(0));
   int min=10,max=20;
   int rand_number=(rand()%(max-min+1))+min;
   cout<<rand_number<<endl;
}

1 main.cpp #include <iostream> 2 #include <stdlib.h> 3 #include <time.h> using namespace std; 5 int main() 7-{ 8 srand(time()

2.

Source code:

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int main()
{
   srand(time(0));
   int min=97,max=121; // because ascii value of 'a'=97 and 'y'=121
   int rand_number=(rand()%(max-min+1))+min;
   cout<<char(rand_number)<<endl;
}

1 main.cpp #include <iostream> 2 #include <stdlib.h> 3 #include <time.h> 4 using namespace std; 5 int main() 7-{ 8 srand(time

3.

Source Code:

#include <iostream>
using namespace std;

int main()
{
   char c='A';
   string str="";
   str=str+char(c+1)+char(c+2)+char(c+3);
   cout<<str<<endl;
}

main.cpp 1 #include <iostream> 2 using namespace std; 3 4 int main() 5-{ 6 char c=A; 7 string str=; str=str+char(C+1)+cha

Add a comment
Know the answer?
Add Answer to:
Answer: cout << k/(i+j) Q1) Provide code that outputs a random number 10 through 20? Q2)...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How many Iterations will this while loop perform? int ico), j(10); cout << "i = "...

    How many Iterations will this while loop perform? int ico), j(10); cout << "i = " << i << endl; cout << "j = " << j << endl; while (i > j) { cout << "j-" « j << endl; j += 2; cout << "i = " << i << endl; } cout << "i = << i << endl; cout << "j = " << j << endl; 5 6 C 8 10 Infinite times Does the...

  • C++ ONLY! Consider the following code and answer the questions in the table below. #include <iostream>...

    C++ ONLY! Consider the following code and answer the questions in the table below. #include <iostream> template <typename T, int N=10> class Array { private:   T array[N+1]; public:   Array() {     for(int i=0; i<N+1; i++) array[i] = 0;   }      T& operator [] (int index) {     if (index>N || index < 0)       return array[N];     else       return array[index];   }   template <typename S>   Array<T,N>& operator= (S &other) {     for(int i=0; i<N+1; i++)       array[i] = other[i];         return *this;   } }; template <typename T, typename...

  • so i have my c++ code and ive been working on this for hours but i...

    so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

  • 2. Design the logic for a program that outputs every number from 1 through 15. 3....

    2. Design the logic for a program that outputs every number from 1 through 15. 3. Design the logic for a program that outputs every number from 1 through 15 along with its value times 10 and times 100. // please answer e, f, 2, 3 <----- 1. What is output by each of the pseudocode segments in Figure 5- 30? b. a. C. d=4 1 a = g4 h 6 while g< h b 2 e 6 f 7...

  • 05/0172019 Q1: (20) Choose one of these C code fragments and write it in PIC24 assembly form. if (u16 i< u16 k) |I True if((u 16-i <ul6k) && TAR (ul6j_u16_p)11 (16.9 !=0)) { if body...

    05/0172019 Q1: (20) Choose one of these C code fragments and write it in PIC24 assembly form. if (u16 i< u16 k) |I True if((u 16-i <ul6k) && TAR (ul6j_u16_p)11 (16.9 !=0)) { if body Falttau 16-j != 80)) { if body else else else-body else-body f code rest of code s else. 05/0172019 Q1: (20) Choose one of these C code fragments and write it in PIC24 assembly form. if (u16 i

  • Could you please do these questions using C and provide the codes and outputs for all...

    Could you please do these questions using C and provide the codes and outputs for all question? Thank you! ° Chapter 17-page 454 Exercise #5 has a question-code the problem and run it to determine the answer - Take a screenshot of the code and the answer Suppose that f and p are declared as follows: struct 5. union char a, b; int c int e (5] Which of the following statcments are legal? (b) p->e(310; (d) p->d->c20; o Chapter...

  • I don't know how to terminate the code in the second time that whether or not...

    I don't know how to terminate the code in the second time that whether or not the users want to continue to get a new number. PLEASE HELP. To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed...

  • Use the following macroeconomic model to answer questions from Q1 through Q11: C 115 + 0.75Yd,...

    Use the following macroeconomic model to answer questions from Q1 through Q11: C 115 + 0.75Yd, where C = Consumption function; Yd (Y-T-Disposable income I 150; Investment G-200; G Government expenditure T-100; T = Tax revenue 40; X = Export M = 30; M-Import Also assume that Yf Full employment GDP (potential GDP) 2,000 a1. Estimate the equilibrium GDP level (income, Ye). Q2. Estimate the level of aggregate consumption (C) Q3. Estimate the level of aggregate saving (S) Q4. The...

  • can you do Part B with the new q2 value. i know the correct answer but...

    can you do Part B with the new q2 value. i know the correct answer but can you show how you get it bc i keep getting 20.7 degrees below the axis. thanks <Homework-1 Practice Problem 17.04 - Enhanced - with Feedback 2 of 6 • Comple Review I Constant Previous Answers Now we will consider a two-dimensional arrangement of charges (Figure 1). A point charge 2.0 C is located on the positive y axis at y=0.30 m, and an...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT