1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rama09 [41]
3 years ago
12

I need to create a function that returns Pascal's Triangle with n rows, where n is an int argument.

Computers and Technology
1 answer:
Ede4ka [16]3 years ago
6 0

A function that returns Pascal's Triangle with n rows:

//import necessary headers

public class Pascal_Triangle {

   // calculate factorial  

   static int factorial(int n)

   {

       int fact = 1;

       int i;

       for(i=1; i<n; i++)

       {

           fact*=i;

       }

       return i;

   }

   // Actual code to display the //pascal triangle

   static void display(int n)  

   {

       int i;

       int line;

       for(line=1;line<=n;line++)

       {

           for(i=0;i<=line;i++)

           {

               System.out.print((factorial(line)/factorial(line-i) * factorial(i)) + " ");

           }

           System.out.println();

       }

   }

   // To read user input

   public static void main(String[] args){  

       BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));

       int n;

       System.out.println("Enter the size for creating Pascal triangle");

       try {

           n = Integer.parseInt(breader.readLine());

       }

       catch(Exception e){

           System.out.println("Please enter a valid Input");

           return;

       }

       System.out.println("The Pascal's Triangle is");

       display(n);

   }

}

You might be interested in
In high-tech fields, industry standards rarely change.<br> True <br> False
Sophie [7]

Answer: false

Explanation:

5 0
2 years ago
I am trying to make a flowgorithm chart for a dogs name, age, weight and when their weight is less than 50 OR more than 100 its
kumpel [21]

Answer:

i think it helps

Explanation:

sorry there was someone else rude as heck messaging and responding I couldn't see their screen name

what isig naame

oh okay

I have sent dm

i dont know your name there

5 0
2 years ago
An operating system is defined as hardware that converts software into a useful form for applications.
marissa [1.9K]

Hardware that transforms software into a form that is helpful for applications is referred to as an operating system. False. Hardware conversion is done by software.

<h3>What is an operating system?</h3>
  • Computer hardware and software resources are managed by an operating system (OS), which also offers common functions for software programs.
  • Operating systems that use time-sharing plan activities to make the most of the system's resources.
  • They may also contain accounting software to allocate costs for processing time, mass storage, printing, and other resources.
  • An operating system (OS) is a piece of software that controls all of the other application programs in a computer after being originally loaded by a boot program.
  • Through a specified application program interface, the application programs seek services from the operating system (API).

To learn more about operating system, refer to:

brainly.com/question/22811693

#SPJ4

4 0
1 year ago
Assume the following variable definition appears in a program:
AnnZ [28]

Answer:

cout << setprecision(2)<< fixed << number;

Explanation:

The above statement returns 12.35 as output

Though, the statement can be split to multiple statements; but the question requires the use of a cout statement.

The statement starts by setting precision to 2 using setprecision(2)

This is immediately followed by the fixed manipulator;

The essence of the fixed manipulator is to ensure that the number returns 2 digits after the decimal point;

Using only setprecision(2) in the cout statement will on return the 2 digits (12) before the decimal point.

The fixed manipulator is then followed by the variable to be printed.

See code snippet below

<em>#include <iostream>  </em>

<em>#include <iomanip> </em>

<em>using namespace std;  </em>

<em>int main()  </em>

<em>{  </em>

<em> // Initializing the double value</em>

<em> double number = 12.3456;  </em>

<em> //Print  result</em>

<em> cout << setprecision(2)<< fixed << number;  </em>

<em> return 0;  </em>

<em>}  </em>

<em />

4 0
3 years ago
Give the names of two different places you might find a number represented in hexadecimal
Paladinen [302]

Answer:

Monday or Tuesday or Wednesday I am going back to work

Explanation:

8 0
2 years ago
Other questions:
  • What are the three main purposes of an operating system? Explain how the old mainframe computers were different from the compute
    12·1 answer
  • That is Entrepreneur ? ?<br>​
    8·1 answer
  • When you are working on an unsaved document on a PC, where is the document temporarily saved?
    5·1 answer
  • What are two advantages of encrypting data stored in the computer system?
    5·1 answer
  • Click on the _____ tab on the ribbon to open the backstage view.
    7·1 answer
  • For this exercise, you'll use the Rectangle class below (you can assume that the length and width are measured in feet).
    12·1 answer
  • Instead of sending an entire file in one big chunk across the​ Internet, __________ is used which dices the file up into little
    12·1 answer
  • How are satellite radio, Internet radio, and podcasting different?
    11·1 answer
  • Universal containers set the organization-wide defaults for cases to private. When a case is escalated, case ownership changes t
    13·1 answer
  • The process of arranging the item of a column in some sequence or order is known as?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!