c patterns level 2

/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/


#include <stdio.h>

int main()
{
    int i,j,k=1,l=9,tmp;
    for(i=1,k=1;i<=10;i++,k=k+2,l--){
          tmp=l;
        for(j=1;j<=19;j++){
         
          if(j<=k){
           
           if(j<=i) {
               ++tmp;
               if(tmp!=10) printf("%d",tmp);
               else printf("0");
           }
           else {
               --tmp;
               if(tmp!=10) printf("%d",tmp);
               else printf("0");
           }
          }
         
         
         
         
   
        }
       
       
        printf("\n");
       
       
    }

    return 0;
}



/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/



#include <stdio.h>

int main()
{
    int i,j,tmp=8;
    
    for(i=1;i<=8;i++,tmp--){
        
        for(j=1;j<=4;j++){
        
          
         if(i<5){
          if(j>i) printf(" ");
          else j!=1?printf("*%d",i):printf("%d",i);
         }
    else{
        if(j<10-i)  j!=1?printf("*%d",tmp):printf("%d",tmp);
          else printf(" ");
    }
    
    
    
        }
        
        
        printf("\n");
        
        
    }

    return 0;
}

Comments

Popular posts from this blog

aaabb to32 ,aabbb to a2b3 convert in c-asr

a2b3 output aabbb c program and beautiful use of getchar() ,isdigit() ,atoi() functions and stdlib.h header file-asr

C program to print square spiral number pattern - asr