Program To Create Pyramid of Star in C: View Plain Print ?
Program To Create Pyramid of Star in C: View Plain Print ?
view plainprint?
1. #include<stdio.h>
2. #include<conio.h>
3. void main()
4. {
5. int i,j,k,s,n;
6. printf(" ENTER THE NO OF ROWS");
7. scanf("%d",&n);
8.
9. for(i=1,s=n;i<=n;i++,s--)
10. {
11. for(k=1;k<=s;k++)
12. printf(" ");
13. for(j=1;j<=i;j++)
14. printf("*");
15. printf(" ");
16. }
17. getch();
18. }
19.
20. </conio.h></stdio.h>
view plainprint?
1. #include<stdio.h>
2. #include<conio.h>
3. void main(void)
4. {
5. clrscr();
6. int i,j,k,l,b,n;
7. printf("Enter the value of N:");
8. scanf("%d",&n);
9. for(i=0;i<=n;i++)
10. {
11. printf(" ");
12. for(l=0;l<=i;l++)
13. printf(" ");
14. for(j=i+1;j<=n;j++)
15. printf("%d",j);
16. for(k=n-1;k>i;k--)
17. printf("%d",k);
18. }
19. b=n-1;
20. for(i=0;i<=n-1;i++)
21. {
22. printf(" ");
23. for(l=n-2;l>=i;l--)
24. printf(" ");
25. for(j=b;j<=n;j++)
26. printf("%d",j);
27. for(k=n-1;k>=b;k--)
28. printf("%d",k);
29. b--;
30. }
31. getch();
32. }
33.
34.
35. </conio.h></stdio.h>
1. int palindrome( char* string )
2. {
3. int i = 0, j = strlen( string ) - 1;
4.
5. while( i < j / 2 )
6. {
7.
8. if( string[ i++ ] == string[ j-- ] )
9. ;
10. else
11. {
12. printf( "The String is not Palindrome" );
13. return -1;
14. }
15. }
16.
17. printf( "The string is Palindrome" );
18. return 0;
19. }
20.
21. int main( )
22. {
23. palindrome( "Info " );
24. palindrome( "Computers" );
25. return 0;
26. }
1. #include<stdio.h>
2. #include<conio.h>
3.
4. /*Program to multiply two 3*3 matrices*/
5.
6. void main()
7. {
8. int a[3][3],b[3][3],c[3][3],i,j,k;
9. clrscr();
10.
11. printf("Enter elements of A:");
12. for(i=0;i<=2;i++)
13. for(j=0;j<=2;j++)
14. scanf("%d",&a[i][j]);
15.
16. printf("Enter elements of B:");
17. for(i=0;i<=2;i++)
18. for(j=0;j<=2;j++)
19. scanf("%d",&b[i][j]);
20.
21. printf("A:");
22. for(i=0;i<=2;i++)
23. {
24. for(j=0;j<=2;j++)
25. printf("%d ",a[i][j]);
26. printf(" "); //To change line.
27. }
28.
29. printf("B:");
30. for(i=0;i<=2;i++)
31. {
32. for(j=0;j<=2;j++)
33. printf("%d ",b[i][j]);
34. printf(" ");
35. }
36. k=0;
37. while(k<=2)
38. {
39. for(i=0;i<=2;i++)
40. {
41. int sum=0;
42. for(j=0;j<=2;j++)
43. sum=sum+a[i][j]*b[j][k];
44. c[i][k]=sum;
45. }
46. k++;
47. }
48. printf(" Result: ");
49. for(i=0;i<=2;i++)
50. {
51. for(j=0;j<=2;j++)
52. printf("%d ",c[i][j]);
53. printf(" ");
54. }
55. getch();
56. }
57. </conio.h></stdio.h>
1. #include <stdio.h>
2. #include <conio.h>
3. main()
4. {
5. int a,b;
6. clrscr();
7. printf("enter the value of a=");
8. scanf("%d",&a);
9. printf("enter the value of b=");
10. scanf("%d",&b);
11. while(a-b>=b)
12. {
13. a=a-b;
14. }
15. printf("the reminder is =%d",a-b);
16. getch();
17. }
18.
19. </conio.h></stdio.h>
decimal number into binary number system
1. #include<stdio.h>
2. #include<conio.h>
3. #include<math.h>
4.
5. void dec_bin(long int num) // Function Definition
6. {
7. long int rem[50],i=0,length=0;
8. while(num>0)
9. {
10. rem[i]=num%2;
11. num=num/2;
12. i++;
13. length++;
14. }
15. printf("\nBinary number : ");
16. for(i=length-1;i>=0;i--)
17. printf("%ld",rem[i]);
18. }
19. //================================================
20. void main()
21. {
22. long int num;
23. clrscr();
24.
25. printf("Enter the decimal number : ");
26. scanf("%ld",&num);
27.
28. dec_bin(num); // Calling function
29.
30. getch();
31. }
32.
33.
34. </math.h></conio.h></stdio.h>