Search C Program | nimishsoft@gmail.com

Number Pattern - 23

12344321
123**321
12****21
1******1

#include<stdio.h>
int main()
{
  int i,j,k;
  for(i=4;i>=1;i--)
  {
    for(j=1;j<=4;j++)
    {
      if(j<=i)
        printf("%d",j);
      else
        printf(" ");
    }
    for(j=4;j>=1;j--)
    {
      if(j<=i)
        printf("%d",j);
      else
        printf(" ");
    } 
    printf("\n");
  }
  return 0;
}


Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C


13 comments:

  1. sir this is completely wrong...

    ReplyDelete
  2. yes..this is not working..second loop will never run!!

    ReplyDelete
  3. sorry for the above comment...the logic is absolutely correct...

    ReplyDelete
  4. It is perfect just in printf("*") instead of printf(" ") in both the cases

    ReplyDelete
  5. yes the code is crct only printf statmnt must be changed

    ReplyDelete
  6. #include

    int main()
    {
    int r,i,j,s,k;

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

    for(i=r;i>=1;i--)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",j);
    }

    for(s=1;s<=2*(r-i);s++)
    {
    printf("*");
    }

    for(k=i;k>=1;k--)
    {
    printf("%d",k);
    }
    printf("\n");
    }
    }

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. public class Patt10 {

    public static void main(String[] args) {

    for(int i=4;i>=1;i--)
    {

    for(int j=1;j<=4;j++)
    {
    if(j>i) {
    System.out.print("*");
    }
    else
    {
    System.out.print(j);
    }
    }

    for(int k=4;k>=1;k--) {

    if(k>i)
    System.out.print("*");
    else
    System.out.print(k);
    }



    System.out.println();
    }

    }

    ReplyDelete
  9. I want to know code for
    12344321
    123**321
    12****21
    1******1
    12****21
    123**321
    12344321

    ReplyDelete
  10. 543212345
    5432_2345
    543___345
    54_____45
    5_______5

    ReplyDelete
  11. //C++ Code
    #include
    using namespace std;
    int main(){
    int N,i,j;
    int k;
    cout<<"Enter number of rows:-"<>N;
    for(i=1;i<=N;i++){
    k=1;
    int l=N-1;
    for(j=1;j<=N;j++){

    if(j<=N+1-i){
    cout<=N+i){
    cout<<k;
    k--;
    }
    else
    {
    cout<<"*";
    }
    }
    cout<<endl;
    }
    }

    ReplyDelete
  12. #include
    using namespace std;
    int main(){
    int n;
    cin>>n;
    int i=1;
    while(i<=n){
    int j=1;
    while(j<=n-i+1){
    cout<=1){
    cout<<j;
    j--;
    }
    cout<<endl;
    i++;
    }
    }

    ReplyDelete