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 Java code to generate 100 random integers ranging from 0..9, inserting each element into an...
Write Java code to generate 100 random integers ranging from 0..9, inserting each element into an ArrayList. Then search for the first instance of the number 3, print the position, and then remove it from the list.
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))
R Simulation:Write an R code that does the following: (a) Generate n samples x from a...
R Simulation:Write an R code that does the following: (a) Generate n samples x from a random variable X that has a uniform density on [0,3]. (b) Now generate samples of Y using the equation: y = α x + β (c) For starters, set α = 1, β = 1.
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...
Write a code on Jupytor notebook: On a roulette wheel, the pockets are numbered from 0...
Write a code on Jupytor notebook: On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are as follows: Pocket 0 is green. For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered pockets are black. For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered pockets are red. For pockets 19 through 28, the odd-numbered pockets are red and the even-numbered pockets are black. For pockets...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT