Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


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


I want C Program to Print Pascal Triangle.

Advertisement
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 Tutorials/Questions & Answers:
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
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
Advertisements
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
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 to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334..., that is why I choosed Java Beginners, but please give me a C program
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
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
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
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
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
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
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
How to print a equilateral triangle patren with numbers
How to print a equilateral triangle patren with numbers  I figure out how to use for loop to print the triangle but i couldn't get the exact values as this http://im37.gulfup.com/FzrOb.jpg could you please help me
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
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
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
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 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 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
triangle
triangle  how to draw triangle numbers with stars in html with the help of javascript
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
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
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++ 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 program
c program  How to convert binary digits to decimal number without using power function
c program
c program  WAP to show the area of a perimeter of a rectanglar by using input command
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
Print Output in C LAnaguage - Development process
Print Output in C LAnaguage  I want to Print Following Output in C Language with Combined For Loops Not Seprate Loops pleaseHelp Me
Write a program to print using for loop
Write a program to print using for loop  Write a program to print using for loop * * * *  
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 - 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
triangle output
triangle output  program to get the following output
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
method overloading in c program
method overloading in c program  how is method overloading in C program is different from C++ program
malloc in c example program
malloc in c example program  What is malloc in c? Please explain the term using an example in C program. Thanks
C Program with Database Connectivity
C Program with Database Connectivity  How To Connect MySQL Database in C Program with Graphics
c program - Java Beginners
c program  Write a program to encrypt a string and decrypt
C program - SQL
C program  Write a C program for airport simulation using queue data structures. Please reply me
c program - IoC
c program  given the string "wordprocessing",write a program to read the string from the terminal and display the same in the following formats: a) word processing b) word processing c) w.p.
c program - Java Beginners
c program  1. How to write a program to Add 2 numbers without using int .size should be more than machine size
C Program - Development process
C Program  C program to find division of two fraction number without...: #include #include #include int main () { int a; int b; int c; int... in the form a/b: "); scanf("%d/%d", &c, &d); nr=a*d; dr=b*c; printf("%d/%d",nr,dr
C Programming SubString Program
C Programming SubString Program  Sir I want to Check whether the Single Substring is present in the given 3 string. characters. eg if i entered... entered to check PROGRAM is exists in given three strings then output
c++ program of inheritance
c++ program of inheritance   Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current.... (b) Display the balance (c) Compute and deposit interest. (d) Permit
C++ program not running
C++ program not running  Hi, this program need to ask 10 random questions with a random month name. Example: RUN How many days are there in the month of March? 28 No March has 31 days. How many days are there in the month
 

 

 

DMCA.com