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
A security administrator is analyzing a user report in which the computer exhibits odd network-related outages. The administrato
elena-s [515]

Answer: Session Hijacking

Explanation:Session hijacking is the attacking activity that threats the valid session of the computer. This attack also invokes the system with unauthorized access for hacking the information and other processes.

Other options are incorrect because crpto-malware is the ransomware that demands ransom for data encrypted by the hackers, rootkit  permits the authorized access in system without getting noticed and logic bomb is a malicious code to harm the program computing. Thus, the correct option is session hijacking.

8 0
3 years ago
When date is processed into a meaningful form, i becomes _______.
mrs_skeptik [129]

Answer:

When date is processed into a meaningful form, it becomes information.

6 0
3 years ago
Which area of a magazine cover is often important for those shops and stalls that cannot display the entire cover page on a stan
zloy xaker [14]

I think the answer is one fourth.

Because usually only that part is visible in a stand. It usually contains the name of the magazine and a little bit of illustration gives an idea about what it is about.

6 0
3 years ago
A _____ is a valuable tool that enables a user to find information on the Web by specifying words or phrases known as keywords,
svetoff [14.1K]

Answer:

Search Engine

Explanation:

A search engine refers to a computer application software that looks through and locates items in a database. These items will correspond to to the phrases or keywords being searched for that has been entered by a user.

On the internet or web, popular search engines are provided by google and yahoo and they are designed to carryout web search when users enter search query as keywords or phrases

8 0
3 years ago
Read 2 more answers
Which of the following is lost when the computer is turned off?
Sergeeva-Olga [200]

Answer:

Memory (RAM) is lost when computer is turned off.

6 0
3 years ago
Other questions:
  • Create a single line comment that says ""Print results to screen""
    13·1 answer
  • HELP I am in the computer lab right now and I need legit reasons why i should work on a laptop instead of a computer. I dont lik
    5·2 answers
  • A(n) ____ database is an application appropriate for an object-oriented database that contains text links to other types of docu
    7·1 answer
  • Consider whether there are additional components that could be added to the IPv4 protocol to enhance its usefulness. What are th
    15·1 answer
  • IT organizations implement powerful information systems like ERP and SCM that provide centralized data repositories. In addition
    11·2 answers
  • A disadvantage of online surveys is that _________. a. it is difficult to access large numbers of potential respondents. b. they
    10·1 answer
  • Write down the functions of network layer in your own words.ASAP
    14·1 answer
  • 3 alternativas donde puedas utilizar la tecnologia que nos ayude a reducir el impacto ambiental al medio ambiente
    14·1 answer
  • Clara works behind a computer all day. She gets a lot of headaches, and her eyes have been hurting her lately. Her doctor diagno
    15·1 answer
  • Identify an internal user who uses product lifecycle management (plm) software and its data.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!