Home Answers Viewqa Development-process C Program to Print Pascal Triangle

 
 


sushant
C Program to Print Pascal Triangle
8 Answer(s)      3 years and 4 months ago
Posted in : Development process

I want C Program to Print Pascal Triangle.
View Answers

January 13, 2010 at 10:44 AM


Hi Friend,

Try the following code:

#include<stdio.h>
#include<conio.h>

void main(){

int a[15][15],i,j,rows,num=25,k;
printf("\n enter the number of rows:");
scanf("%d",&rows);
for(i=0;i<rows;i++){
for(k=num-2*i;k>=0;k--)
printf(" ");
for(j=0;j<=i;j++){
if(j==0||i==j){
a[i][j]=1;
}
else{
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
printf("%4d",a[i][j]);
}
printf("\n");
}
getch();
}

Thanks

September 18, 2011 at 1:01 AM


  1. Diamond * * * * * main() { int i,j,rows,num=25,k,l,m; printf("enter the no of rows"); scanf("%d",&rows); for(i=0;i=0;k--) printf(" "); for(j=0;j<=2i;j++) printf("*"); printf("\n"); } for(l=i;l=0;k--) printf(" "); for(m=0;m<(rows/2-1);m++) printf("*"); printf("\n"); i--; } } code by vinod pragati clg - List item


September 18, 2011 at 1:06 AM


  1. ![

    [> Diamond c program

       *   main() {
    
        int i,j,rows,num=25,k,l,m;
        printf("enter the no of rows");
        scanf("%d",&rows); for(i=0;i=0;k--)
        printf(" "); for(j=0;j<=2i;j++)
        printf("*"); printf("\n"); }
        for(l=i;l=0;k--) printf(" ");
        for(m=0;m<(rows/2-1);m++)
        printf("*"); printf("\n"); i--; } }
        code by vinod pragati clg - List
        item][1]
    

    ][1]

    [1]: http://


September 18, 2011 at 1:11 AM


Diamond c program

  • main() {

    int i,j,rows,num=25,k,l,m;
    printf("enter the no of rows");
    scanf("%d",&rows); for(i=0;i<rows/2;i++)
    {
    for(k=num-i;k.=0;k--)
    printf(" "); for(j=0;j<=2i;j++)
    printf("*"); printf("\n"); }
    for(l=i;l<rows;l++) { for(k=num-(i-2);k>=0;k--)  printf(" ");
    for(m=0;m<(rows/2-1);m++)
    printf("*"); printf("\n"); i--; } }
    code by vinod pragati clg - List
    item][1]
    

May 10, 2012 at 1:48 PM


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[20][30],n;
printf("enter the no of rows");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=0;j<i;j++)
{
if(i<2)
{a[i][j]=1;
printf("%d\t",a[i][j]);
}
else
{
a[i][j]=a[i-1][j-1]+a[i-1][j]
printf("%d\t",a[i][j]);
}
}
printf("\n");
}
getch();
}

May 30, 2012 at 12:43 AM


printf("using only one dimensional array") ;

int n1  = (rows * (rows+1))/2 ;
int b[n1];
int p = 1;

for(int i = 0 , j = 0 ; i < n ; ++i , ++j)
{
    int k = i+j ;

    b[j] = 1 ;
    //printf("%d",b[j]);

    if(j < k )
    {
        ++j ;

        while(j < k)
        {
            b[j] = b[p] + b[p + 1] ;
            //printf("\t%d",b[j]);
            ++j ;
            ++p;
        } 
        b[j] = 1 ;
        //printf("\t%d",b[j]);
        if( i > 1)
            ++p;

    }
//printf("\n");
}

May 30, 2012 at 12:53 AM


Pascals triangle using 1D array

    int n1  = (rows * (rows+1))/2 ;
    int b[n1];
    int p = 1;

    for(int i = 0 , j = 0 ; i < n ; ++i , ++j)
    {
        int k = i+j ;

        b[j] = 1 ;
        //printf("%d",b[j]);

        if(j < k )
        {
            ++j ;

            while(j < k)
            {
                b[j] = b[p] + b[p + 1] ;
                //printf("\t%d",b[j]);
                ++j ;
                ++p;
            } 
            b[j] = 1 ;
            //printf("\t%d"b[j]);
            if( i > 1)
                ++p;

        }
    //printf("\n");
    }

November 28, 2012 at 8:32 PM


pls can any one give me code...to make pascal triangle with recursion









Related Pages:
C Program to Print Pascal Triangle - Development process
C Program to Print Pascal Triangle  I want C Program to Print Pascal Triangle.  Hi Friend, Try the following code: #include #include void main(){ int a[15][15],i,j,rows,num=25,k; printf("\n enter
pascal triangle
the following link: C Pascal's Triangle Thanks...pascal triangle   given string : char str[]="123456789"; write a program in 'c'-language that displays the following: 1 232
C Print Pascal Triangle
C Print Pascal Triangle In this section, you will learn how to display Pascal's triangle. A Pascal's triangle is a geometric arrangement of the binomial coefficients in a triangle.The rows of Pascal's triangle are conventionally
triangle
valid integers will be entered) Determine and print if they could represent the sides of a triangle If they can form a triangle, determine and print if they can...triangle  Write a program that makes use of a class called
A Program To Print A Equilateral Triangle
A Program To Print A Equilateral Triangle  Write A program to Print Following In Java : 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
C program - Java Magazine
C program  develop a simple program in C that allows a user to enter..., the program should print the following; The three integers form a Right-angled...", &c); if((a==b)&&(b==c)&&(c==a)){ printf("Equilateral Triangle \n
write a program to use for loop print **********========== in c language
write a program to use for loop print **********========== in c language  write a program to use for loop print **========== in c language
write a program in C to print following triangles on the screen
write a program in C to print following triangles on the screen  write a program in C to print following triangles on the screen
Java Program Floyd's Triangle
Java Program Floyd's Triangle In this section you will read about how to write a Java program to print Floyd's triangle. This tutorial is about... for creating the Floyd's triangle in Java. Before writing a Java program
triangle shape
triangle shape  Hi, I have to create a program which its output is: + ++ +++ ++++ and this what I did so far : package symbols; import... symbol; System.out.print(" how many lines you want to print? "); nline
how to write a program in java to print numbers in equalateral triangle
how to write a program in java to print numbers in equalateral triangle  the output must be 1 324 76589   Here is an example of pattern 1 2 3 4 5 6 7 8 9 Example: public class NumberTriangle{ public
C Program to Print Stras - Development process
C Program to Print Stras  How I can Print Following Output using Two For loops in C Language? * * * * * * * * * * * * * * * *  Hi Friend, Try the following: #include #include void main(){ int i=0
C Program to Print Following Output - Development process
C Program to Print Following Output  Hello Sir I wnat to print Followning output in C Language with for loop How I Can Print it? 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1  Hi Friend, Try the following: #include
How to print the following output using c program
How to print the following output using c program  1) 4 3 4 2 3 4 1 2 3 4 2) A B C D E F G H I J
Triangle program
a program for this triangle    1 121 12321 1234321 write a program for this triangle    1 121 12321 1234321 write a program...Triangle program  1 121 12321 1234321 123454321 kindly give
Triangle Program
Triangle Program  i want program code for 1 2 3 4 5 6 7 8 9 10 any body please help me   public class Triangle { public static void main(String[] args
C and C++ books-page10
C and C++ books-page10       The programming language C As a programming language, C is rather like Pascal or Fortran. Values are stored in variables. Programs are structured
C program
a function to print names of all students who joined in a particular year. (c)Write a function to print the data of a student whose roll number is given...C program  hi, here is my question: Create a structure to specify
program in c
program in c  Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement. For example: 1 3
Write a program to construct a triangle with the ?*?
Write a program to construct a triangle... of times we have to print *.  Now compile and run the program and insert... programming will teach you the coding for constructing a shape of triangle by using
c program
c program  plz send me program for this. write a program to print the following code? (in c language) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10
c++
on an object of type dayType: a. Set the day. b. Print the day. c. Return the day...c++  Write the definition of the class dayType that implements the day of the week in a program. The class dayType should store the day
c program
c program  plz send me program for this. write a program to print the following code? 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10 11 12 3 4
print rectangle triangle with ?*? using loops
print rectangle triangle with ?*? using loops   * * * * * * i want print like this.what is the code?   import java.lang....("*"); } } System.out.print(" "); } } print("code sample");   class Traingles { public
how java programming differ from pascal and C - Java Beginners
of this type, The statements used between C and Pascal are roughly analogous... value, and then its Pascal equivalent: /* 11 */ // C version double...how java programming differ from pascal and C  how Does the Java
triangle output
triangle output  program to get the following output
triangle output
triangle output  program to get the following output: * *   Hi Friend, Please specify the pattern properly. Thanks
Triangle problem
Triangle problem  what's the logic for create pattern program how can i create any pattern program with in minute. like this 1 2 5 3 6 8 4 7 9 10
C program - SQL
C program  write a C program to print multiplication table using pointers.  Hi Friend, Try the following code: #include #include void main() { int i,j; int * pt; clrscr(); printf(" "); printf("\n
about a program in c language
about a program in c language   Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement
Write a java program that prints the decimal representation in reverse. (For example n=173,the program should print 371.)c
Write a java program that prints the decimal representation in reverse. (For example n=173,the program should print 371.)c  class rose { int n...); System.out.println("\nReverse the number"+i); S.out(); } }   print
Floyd's triangle
Floyd's triangle  Write a 'for' statment that will print Floyd's traingle.   Hi Friend, Try the following code: public class FloydTriangleExample { public static void main(String[] args) throws Exception { int k=0
C/C++ Programming Books
form of, say, Pascal, then at the outer level the layout of a C program may...;  C Programming Books A C program... in the dictionary.Variables are the "words" for the C language. In a program, variables have
print the below pattern
print the below pattern  to write a program using a function ti initialize a character 'A' and print the following pattern of characters upto six lines A A B A B C A B C D A B C D E A B C D E F
print a rectangle - Java Beginners
print a rectangle  how do I print a rectangleof stars in java using...("Give me the size of each triangle : "); int size = Integer.parseInt(n.readLine... static void raster(int a, int b, int c){ String result = ""; for(int Rows
simple program
simple program  how to print * like triangle
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
c programming
c programming  Write a Program in 'C' to print the following output 'n' rows. for example, if n:3, the following should be output by the program : 1 1 2 L r 2 3 2 1 1 2 L 1
c programming
c programming  Write a Program in 'C' to print the following output 'n' rows. for example, if n:3, the following should be output by the program : 1 1 2 L r 2 3 2 1 1 2 L 1
c++ program
c++ program  Write a program which reads a text from the keyboard and displays the following information on the screen in two columns: (a) Number of lines (b) Number of words (c) Number of characters Strings should be left
C Program
C Program  Why doesn't the code int a = 1000, b = 1000; long int c = a * b; work? plz help me sir
c++
c++  Consider the following declarations: class xClass { public: void func(); void print() const; xClass (); xClass (int, double); private: int u... private members does class xClass have? c. How many constructors does class xClass
c program
c program  How to convert binary digits to decimal number without using power function
program to print total marks
program to print total marks  program to input total marks out of 600 marks as an argument and print the stream allotted using the following criteria 401 & above - PCM 301-400 - ZBC 201-300- Commerce 101-200 - Arts
write a program to print
write a program to print   write a program to print following 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1
c++
c++  Consider the following declarations: class xClass { public: void func(); void print() const; xClass (); xClass (int, double); private: int u... private members does class xClass have? c. How many constructors does class xClass
C#
C#  i need a code that will make program perform the basic operations upon the data Listview save, update and cancel
triangle
triangle  how to draw triangle numbers with stars in html with the help of javascript
c++
c++  write a program that gets a key or character from the keyboard and displays it ASII code in decimal, hexadecimal and binary form.It must also give a description of the key pressed
c++
c++  .write a program that accepts 5 subjects of a student,it should have a function to calculate the average & another function to grade.grade should be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.