## INDEX

### Write a c program to print Pascal triangle.

1. Pascal triangle in c without using array

2. C code to print Pascal triangle

3. Simple c program for Pascal triangle

4. C program to generate Pascal triangle

5. Pascal triangle program in c language

6. C program to print Pascal triangle using for loop

#include<stdio.h>

long fact(int);
int main(){
int line,i,j;

printf("Enter the no. of lines: ");
scanf("%d",&line);

for(i=0;i<line;i++){
for(j=0;j<line-i-1;j++)
printf(" ");

for(j=0;j<=i;j++)
printf("%ld ",fact(i)/(fact(j)*fact(i-j)));
printf("\n");
}
return 0;
}

long fact(int num){
long f=1;
int i=1;
while(i<=num){
f=f*i;
i++;
}
return f;
}

Sample output:

Enter the no. of lines: 8
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1

10. Write a c program to add two numbers without using addition operator.
11. Write a c program to subtract two numbers without using subtraction operator.
15. Write a c program to solve quadratic equation.
18. Write a c program which passes structure to function.
28. Write a c program which takes password from user.
29. Write a scanf function in c which accept sentence from user.
30. Write a scanf function in c which accept paragraph from user.

1. good site

2. #include
int main()
{
int i,j,k,n,m;
printf("Enter the range ");
scanf("%d",&n);
m = n-1;
for(i=1;i<=n;i++)
{
k = i;
j = m;
while(j)
{
printf(" ");
j--;
}
while(k)
{
printf("*");
printf(" ");
k--;
}
printf("\n");
m--;
}
}

1. can u please give me solution of this question?
Question: Write program using loop to draw 50 stars in five rows.Through pascal programming language.

2. can u please give me solution of this question?
Question: Write program using loop to draw 50 stars in five rows.Through pascal programming language.

3. dude your code is right but this a code for pyramid

4. please write a program to display all the perfect and prime numbers within a range.
(I tried them, but after entering the range, the screen holds showing nothing.. on further clicking the program execution exits)

5. how to say a number is perfect or not?

6. rose_preethi10/16/11, 12:06 AM

The 6 is a perfect number , because we can divide a 6 by 1,2,3 and if we add 1+2+3 we will get an answer as 6... When the sum of divisior of a particular number is equal to the number then we say that is a perfect number..
Another Example is 28 which is divided by 1,2,4,7,14 and when we add the number we will get as 28, 1+ 2 + 4 + 7 + 14 = 28

7. Hi Pavani,
Which compiler are you using?

8. preema&amp; reema12/12/11, 1:57 PM

good site,thank u.......

9. wat is pascal triangle

10. incomplete,,,,,,,,,,,,, jst luk 1st for loop of i

11. gud clean example

12. simple way with out using function....

#include
#include

void main()
{
int i,j,n,c,k,space;
clrscr();
printf("Enter the limit ");
scanf("%d",&n);
printf("\n\n");
space=n;
for(i=0;i<=n;i++)
{
c=1;
for(k=space;k>=0;k--)
printf(" ");

space--;
for(j=0;j<=i;j++)
{
printf("%d ",c);
c=(c*(i-j)/(j+1));
}
printf("\n");
}
getch();
}

1. Small correction : if we give n rows it will print n+1 rows ,so write I<n in first for loop

13. why hav u used long datatype for fact() function... why d things don't work up with int as a return type???

14. function get more confusion....

15. function get more confusion....

16. lots of confusion.....

17. can u please give me solution for the following pattern
1
2 2
3 3 3
4 4 4 4

1. #include
void main()
{
int x,y;
for(x=1;x<=4;x++)
{
for(y=1;y<=x;y++)
printf("%2d",x);
printf("\n");
}

}

2. #include
int main ()
{
int i,j,a=1;
for(i=1;i<=4;i++){
for(j=1;j<=i;j++){
printf ("%d ",a);
}
a++;
printf ("\n");
}
getchar();
return 0;
}

18. send code for fallowing o/p::
1
2 3
4 5 6
7 8 9 10

1. #include
int main()
{
int r,n,c;
printf("Enter the limit ");
scanf("%d",&n);
int s=n;
for(r=0;r<n;r++)
{
for(c=1;c<=s;c++)
{
printf("%d ",c);
}
s--;
printf("\n");
}
return;
}
by Muthusamy.s from GCT

2. #include

int main()
{
int n, i, c, a = 1;

printf("Enter the number of rows of Floyd's triangle to print\n");
scanf("%d", &n);

for (i = 1; i <= n; i++)
{
for (c = 1; c <= i; c++)
{
printf("%d ",a);
a++;
}
printf("\n");
}

return 0;
}

19. can u please give me solution for the following pattern...
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

1. thank u

2. #include
int main()
{
int r,n,c;
printf("Enter the limit ");
scanf("%d",&n);
int s=n;
for(r=0;r<n;r++)
{
for(c=1;c<=s;c++)
{
printf("%d ",c);
}
s--;
printf("\n");
}
return;
}
by Muthusamy.s from GCT

20. can u pls give me solution for fibonacci series in use for loop...

21. can u pls provide ans for dis
5987
987
87
7

22. provide the answer this question

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1

1. #include
int main()
{
int i,j,n,c;
printf("Enter the limit ");
scanf("%d",&n);
printf("The pascal triangle is print in floyd's triangle\n\n");
for(i=0;i<n;i++)
{
c=1;
for(j=0;j<=i;j++)
{
printf("%d ",c);
c=(c*(i-j)/(j+1));
}
printf("\n");
}
return;
}

by Muthusamy.S GCT

2. Thanx a lot darling...!!!!!!!!

23. stack operations are used for storing elements in a stack. The input method for stack is last in first out. Thank you for sharing this program.
regards:
srinath reddy.
admin of Programming Tutorials for Beginners

24. #include
#include
#include
void main()
{
int a[20],n,n1,num,sum=0,r,i,j;
clrscr();
printf("enter the power of 11");
scanf("%d",&n);
for(i=0;i0)
{
r=num%10;
//sum=sum+r;

printf(" %d ",r);
num=num/10;
}
printf("\n");

}

getch();
}

25. can someone tell me whats wrong with this code for generating pascal triangle .iwish to print the pascal triangle line by line without having to induct spaces among elements

int fact1(int j)
{
int k=1,i;
for(i=j;i>=0;i-- ){
k=i*k;
}
return k;
}

int main()
{
int res,line,k;
for(line=0;line<7;line+=1){
for(k=0;k<line;k++)
{
res=fact1(line)/fact1(line-k)*fact1(k);
printf("%d\t",res);
}
printf("\n");
}
return 0;
}

26. ****** *******
***** *****
*** ***
** **
* *

1. using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication39
{
class Program
{
static void Main(string[] args)
{
int i, j;
for(i=0 ;i<5 ;i++)
{
for(j=5 ;j>i;j--)
{
Console.Write("*");

}
Console.Write(" ");
for (j = 5; j > i; j--)
{
Console.Write("*");

}
}

}
}

}

27. nice but plz give the many pascal question that we butter understand about the pascal.....

28. I have this one works 100% i coded this my self although it's little foolish
#include
main()
{
int i, j, b[50],a[50],k,n,count;
printf("enter the limit \n") ;
scanf("%d", & n) ;

for(i=0;i0;k--)
printf(" ");
printf("1 \n\n");
}
if(j==1)
{
for(k=2*(n-i) ;k>0;k--)
printf(" ");
printf("1 ");
}
}
count=0;
k=0;
for(j=1;j<i;j++)
{
a[1]=1;
a[i]=1;
b[k]=a[j]+a[j+1];
printf(" %d ", b[k]) ;
k++;
count++;
}
for(j=2,k=0;k<=i-1;j++, k++)
a[j]=b[k] ;
for(j=1;j<=i;j++)
{
if(j==i)
{
printf(" 1");
printf("\n\n") ;
}
}
}
return 0 ;
}

30. #include
#include

int main()
{
int a[10][10];
int no;
printf("Enter the number of rows for pascal triangle : ");
scanf("%d",&no); //taking input
for(int i=1; i<=no; i++)
{
for(int j=1; j<=i; j++)
{
if(j==1||j==i)
{
a[i][j]=1;
}
else // taking arrays value
{
a[i][j]=a[i-1][i-j]+a[i-1][i-j+1];
}
}
}
for(int i=1; i<=no; i++)
{
for(int k=1; k<=no-i; k++)
{
printf(" ");
}
for(int j=1; j<=i; j++)
{
printf("%d ",a[i][j]); //printing pascal triangle
}
printf("\n");
}
getch();
}

31. simple easy approach

#include
void main()
{
int i,j,x,n,s;
printf("Enter The Number : ");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
x=1;
for(s=1;s<=n-i;s++)
printf("\t");
for(j=1;j<=i+1;j++)
{
printf("%d\t\t",x);
x=x*(i-j+1)/j;
}
printf("\n");
}
}

32. This comment has been removed by the author.

33. #include
main()
{
int i,j,n,k,temp,c;

printf("Enter the number of lines\n");
scanf("%d",&n);
printf("\n\n");
temp=n;
for(i=0;i<=n;i++,printf("\n"))
{
c=1;
for(k=temp;k>=0;k--)
printf(" ");
temp--;
for(j=0;j<=i;j++)
{
printf("%d ",c);
c=(c*(i-j)/(j+1));
}
}

}

34. This comment has been removed by the author.

35. plz tell me code of this patten:

1*2*3*4*17*18*19*20
-5*6*7*14*15*16
--8*9*12*13
---10*11

36. please i want pointers codes

37. how to do this???

A1234
AB123
ABC12
ABCD1
ABCDE

38. 1
1
2
12
3
123
4
1234

39. if num=3 then
1
2*3
4*5*6
4*5*6
2*3
1

40. C++ Program to Print Triangle of Stars

Print triangle of stars is depend of two concept, first you need outer loop for line break and inner loop for increment and decrements.

41. can you assist me to create a pascal program to output the digital pyramid

42. any 1 can solve tis plzzzzz
1
12
123
12345 tis is a o/p u can gv a sol. plzzzz gv me soon

43. How can we execute with out using factorial.