Question

In: Computer Science

Write a code in two ways to generate all multiple of n: from 0 to 158...

Write a code in two ways to generate all multiple of n: from 0 to 158 included. (this is all the teacher gave me)
1) in procedural style,
2) in Object Oriented style

Input: just a value of n between 11 and 19 included.
Output : the generated list required.


Choose any languages you know.

Keep working hard
-----------------
To do:

1- Read about Styles of PLs :

Procedural Programming Language. ...
Object-oriented Programming Language. ...
Functional Programming Language. ...
Logic Programming Language. ...

Scripting Programming Language. ...


2- Read about these PLs :

C Language. ...
C++ Language. ...
java Language. ...
Python Language. ...

3- Read OOP terminology(or paradigm), prepare yourself to explain them in convincing ways:

data abstraction
encapsulation
messaging
modularity
polymorphism
inheritance

Solutions

Expert Solution

Procedural Style C++ code:

#include<iostream>
using namespace std;

//function to print multiples
void printMultiples(int n){
    for(int i=0;i<=158;i++){
        cout<<n*i<<endl;
    }
}

int main(){
    int n;
    //Enter Value of n
    cin>>n;
    // call function to print multiples
    printMultiples(n);
  
    return 0;
  
}

Please refer to the screenshot of the code to understand the indentation of the code

First few lines of Output:

Hope this helped. Please do upvote and if there are any queries please ask in comments section.


Related Solutions

Write a code in two ways to generate all multiple of n: from 0 to 158...
Write a code in two ways to generate all multiple of n: from 0 to 158 included. 1) in procedural style, 2) in Object Oriented style Input: just a value of n between 11 and 19 included.
Write the R code First, generate 1000 observations from a binomial distribution with n=30 and p=0.2...
Write the R code First, generate 1000 observations from a binomial distribution with n=30 and p=0.2 Use the 1000 observations you generated: a) Generate poisson, binomial, negative binomial Diagnostic Distribution Plots using distplot. b) Generate a histogram and overlay a kernel estimator of the density (You can use: binom <- rbinom(n=1000,size=30, prob=0.2))
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal to n, such that the digit to the right is greater than the left digit (ai+1 > ai). E.g. if n=3 (123,124,125,……129,234,…..789)
Write the code in assembly language to generate two square waves of frequency 1KHZ with 50%...
Write the code in assembly language to generate two square waves of frequency 1KHZ with 50% duty cycle and 10KHZ with 50% duty cycle using P1.0 and P1.1 using timer0 and timer1 simultaneously. Don't use instruction overhead. use timer interrupts to implement the functionality use Xtal=12MHZ
Write the R code to generate five independent uniform random numbers and use that to generate...
Write the R code to generate five independent uniform random numbers and use that to generate 5 independent Bernoulli random variables with probability of success p = 0.4. please use RStudio. please do not use lab nor rbern for calculations.
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print...
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print out "n" lines as follows: 0 0 1 0 1 2 0 1 2 3 … 0 1 2 3 … n-1
For this problem, you will write a program using two queues. Generate n random numbers between...
For this problem, you will write a program using two queues. Generate n random numbers between 10 and 100 (both inclusive), where n>9. The value of n should be taken as input from the user and n should be >9. The numbers could be duplicated. Enqueue all these numbers to the first queue. The objective is to find the numbers whose sum of digits is odd and enqueue them to the second queue. The remaining numbers (whose sum of digits...
What is the code in Rstudio or R? (a) Generate 200 random samples of size n...
What is the code in Rstudio or R? (a) Generate 200 random samples of size n = 10 from a Poisson distribution with mean λ = 12. i. Calculate sample means for each sample. Report the first 10 sample means. ii. Draw a histogram of the sample means (where the y-axis is the density) and fit a density estimate (default density estimator is ok). iii. What is your finding about the sampling distribution of the sample mean, based on your...
a – DSB. Write the code for an m-file (script) to generate a DSB signal. The...
a – DSB. Write the code for an m-file (script) to generate a DSB signal. The modulating (message) signal is a single tone signal with frequency 1kHz and the carrier frequency is 30kHz. Time Vector: 3001 points over range from 0 to 3ms (3 cycles of the modulating signal). Plot your original message signal both in time and its spectrum. (Note: the Matlab examples 6.1 and 6.2 will help, but use the cosine functions for your signals instead of sine...
What is the value of n after this code runs? 1 Point int n = 0;...
What is the value of n after this code runs? 1 Point int n = 0; int j = 7; if ((j!=0) && (n < 25)) { n = 1; if (j > 4) { n = 2; } else { n = 3; } } else { n = 4; if (j%2 >= 2) { n = 5; } else { n = 6; } }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT