Showing posts with label for. Show all posts
Showing posts with label for. Show all posts

Saturday, 25 August 2012

Loop control structure066

Write a program to construct this figure.
                                              9
                                            8 8
                                          7 7  7
                                        6 6  6  6 
                                     5  5  5  5  5
                                   4  4  4  4  4  4
                                 3  3  3  3  3  3  3
                               2  2  2  2  2  2  2  2
                             1  1  1  1  1  1  1  1  1


#include <stdio.h>
#include <conio.h>

void main ( )
{
       int         i, j, k, l = 35;
       clrscr ( );

       printf ("\n\t\t\t    Design of Numbers\n\n\n");

       for ( i = 9; i >= 1; i-- )
       {
                for ( j = 0; j < l; j++ )
                {
                         printf(" ");
                }
                for ( k = 1; k <= 10 - i; k++ )
                {
                         printf ("%d ", i);
                }
                printf ( "\n" );
                l--;
           }
           getch( );
}



Click here to contact us 

Friday, 24 August 2012

Loop control structure065

Write a program to construct  step of block.

#include <stdio.h>
#include <conio.h>

void main ( )
{
            int         i, j, k, l, m = 10;
            clrscr ( );
                                          
            printf ("\n\t\t\t      Design of step of block\n\n\n\n");
                                        
            for ( i = 1; i <= 6; i++ )
            {                                   
                            for ( j = 1; j <= 6; j++ )
                            {                                      
                                            for ( l = 1; l < m; l++ )
                                            {                                    
                                                            printf(" ");
                                            }                                                                
                                            for ( k = 1; k <= 6; k++ )
                                            {                                          
                                                            printf ("* ");
                                            }                                              
                                            printf ( "\n" );
                            }
                            m = m + 8;
            }
            getch( );
}


Click here to contact us

 Write a program to construct  step of block from reverse side.

#include <stdio.h>
#include <conio.h>

void main ( )
{
    int         i, j, k, l, m = 50;
    clrscr ( );

    printf ("\n\t\t\t      Design of step of block\n\n\n\n");

    for ( i = 1; i <= 6; i++ )
    {
        for ( j = 1; j <= 6; j++ )
        {
            for ( l = 1; l < m; l++ )
            {
                printf(" ");
            }
            for ( k = 1; k <= 6; k++ )
            {
                printf ("* ");
            }
            printf ( "\n" );
        }
        m = m - 8;
    }
    getch( );
}


Click here to contact us

Loop control structure064

Write a program to construct  a Pyramid.

#include <stdio.h>
#include <conio.h>

void main ( )
{
           int         a, b, c, d = 38;
           clrscr ( );
                            
           printf ("\n\t\t\t      Design of Pyramid\n\n\n");
                                           
           for ( a = 1; a <= 10; a++ )
           {                                       
                            for ( c = 1; c <= d; c++ )
                            {                                      
                                             printf(" ");
                            }                                 
                            for ( b = 1; b <= a; b++ )
                            {                                    
                                             printf ("* ");
                            }
                            printf ( "\n" );
                            d--;
           }
           getch( );
}


Click here to contact us

 Write a program to construct  a reverse Pyramid.

#include <stdio.h>
#include <conio.h>

void main ( )
{
           int        a, b, c, d = 29;
           clrscr ( );
                                                              
           printf ("\n\t\t\t      Design of Pyramid\n\n\n");
                                                                          
           for ( a = 10; a >= 1; a-- )
           {                                                                                                    
                              for ( c = d; c >= 1; c-- )
                              {                                                                               
                                               printf(" ");
                              }                                                                          
                              for ( b = 1; b <= a; b++ )
                              {                                                                             
                                               printf ("* ");
                              }                                              
                              printf ( "\n" );
                              d++;
           }
           getch( );
}


Click here to contact us 

Wednesday, 22 August 2012

Loop control structure063

Write a program to construct  the image shown below.
                ABCDEFEDCBA
                ABCDE  EDCBA
                ABCD       DCBA
                ABC            CBA
                AB                 BA
                A                      A

#include <stdio.h>
#include <conio.h>

void main ( )
{
          int        i, j, k, s = -1;
          clrscr ( );
                                      
          printf ("\n\t\t\t\t Design of Alphabets");
          printf ("\n\n\n\n\n\n\t\t\t\t");
                                           
          for ( i = 'F'; i >= 'A'; i-- )
          {                                    
                           for ( j = 'A'; j <= i; j++ )
                           {                                    
                                             printf("%c ", j);
                           }                   
                           for ( k = 1; k <= s; k++ )
                           {                                     
                                            printf ("  ");
                           }                                     
                           s = s + 2;
                           if ( i == 'F' )
                                    j = i - 1;
                           else                        
                                    j = i;
                           for ( ; j >= 'A'; j-- )
                           {                              
                                             printf("%c ", j);
                           }
                           printf ( "\n\n\t\t\t\t" );
          }
          getch();
}



Click here to contact us

Loop control structure062


Write a program to construct  the image shown below.
                                   1
                                 13 
                               135
                             1357
                           13579
                             1357
                               135
                                 13
                                   1

#include <stdio.h>
#include <conio.h>

void main ( )
{
           int          i, j, s;
           clrscr ( );
                                     
           printf ("\n\t\t\t\t Design of Numbers");
           printf ("\n\n\n\n\n\n\n\t\t\t\t");
                                                      
           for ( i = 1; i <= 9; i = i + 2 )
           {                                         
                           for ( s = 9; s >= i; s = s - 2 )
                           {                                           
                                           printf ("  ");
                           }                        
                           for ( j = 1; j <= i; j = j + 2 )
                           {                                          
                                           printf("%d ", j);
                           }
                           printf ( "\n\n\t\t\t\t" );
           }                                                
                                  
           for ( i = 7; i >= 1; i = i - 2 )
           {                                          
                           for ( s = 9; s >= i; s = s - 2 )
                           {                                                    
                                           printf ("  ");
                           }                    
                           for ( j = 1; j <= i; j = j + 2 )
                           {                                   
                                           printf("%d ", j);
                           }
                           printf ( "\n\n\t\t\t\t" );
           }
           getch();
}



Click here to contact us

Loop control structure061

Write a program to construct  the image shown below.
                 
                  1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
                  1 2 3 4 5 6 7 8    8 7 6 5 4 3 2 1
                  1 2 3 4 5 6 7          7 6 5 4 3 2 1
                  1 2 3 4 5 6                6 5 4 3 2 1
                  1 2 3 4 5                      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     



#include <stdio.h>
#include <conio.h>

void main ( )
{
           int         i, j, s = - 1, k;
           clrscr ( );
                                           
           printf ("\n\t\t\t\t Design of Numbers");
           printf ("\n\n\n\t\t\t");
                                           
           for ( i = 9; i >= 1; i-- )
           {                                 
                           for ( j = 1; j <= i; j++ )
                           {                                   
                                           printf("%d ", j);
                           }                                      
                           for ( k = 1; k <= s; k++)
                           {                                     
                                           printf ("  ");
                           }                                             
                           if ( i == 9 )
                                    j = i - 1;
                           else                        
                                    j = i;
                           for ( ; j >= 1; j-- )
                           {                             
                                            printf ("%d ", j);
                           }                                        
                           s = s + 2;
                           printf ( "\n\t\t\t" );
           }
           getch();
}



Click here to contact us






Loop control structure060

Write a program to construct  the image shown below.
                                                *
                                               **
                                              ***
                                            *****
                                          *******
                                        *********
                                      ***********
                                    *************
                                  ***************
                                *****************
                                  ***************
                                    *************
                                      ***********
                                        *********
                                          *******
                                            *****
                                              ***
                                               **
                                                *


#include <stdio.h>
#include <conio.h>

void main ( )
{
            int          i, j, k;
            clrscr ( );
                                   
            printf ("\n\t\t\t   Design of stars");
            printf ("\n\n\n");
                                       
            for ( i = 1; i <= 9; i++ )
            {                                     
                            for ( k = 35; k >= i; k-- )
                            {                                      
                                               printf (" ");
                            }                                         
                            for ( j = 1; j <= 2 * i - 1; j++)
                            {                                                
                                               printf ("*");
                            }                                      
                             printf ("\n");                  
            }                                                                       
            for ( i = 8; i >= 1; i-- )
            {                                                                      
                            for ( k = 35; k >= i; k-- )
                            {                                                       
                                               printf (" ");
                            }                                                              
                            for ( j = 1; j <= 2 * i - 1; j++)
                            {                                            
                                               printf ("*");
                            }
                            printf ("\n");
            }
            getch ( );
}



Click here to contact us

Loop control structure059

Write a program to construct  the image shown below.
                                            1
                                           22
                                         3333
                                       444444
                                    555555555
                                  66666666666
                                7777777777777
                              888888888888888
                            99999999999999999 



#include <stdio.h>
#include <conio.h>

void main ( )
{
                int          i, j, k;
                clrscr ( );
                                             
                printf ("\n\t\t\t   Design of Numbers");
                printf ("\n\n\n");
                                     
                for ( i = 1; i <= 9; i++ )
                {                                   
                                for ( k = 35; k >= i; k-- )
                                {                                     
                                                   printf (" ");
                                }                       
                                for ( j = 1; j <= 2 * i - 1; j++)
                                {                                        
                                                   printf ("%d", i);
                                }
                                printf ("\n");
                }
                getch ( );
}



Click here to contact us

Loop control structure058

Write a program to construct  the image shown below.
                                 1
                               2  3
                            4   5  6
                          7   8   9  10  

#include <stdio.h>
#include <conio.h>

void main ( )
{
           int          i, j, k, m = 1;
           clrscr ( );
                                          
           printf ("\n\t\t\t   Design of Numbers");
           printf ("\n\n\n");
                                        
           for ( i = 1; i <= 4; i++ )
           {                                  
                           for ( k = 35; k >= i; k-- )
                           {                                   
                                              printf (" ");
                           }                                         
                           for ( j = 1; j <= i; j++)
                           {                                 
                                              printf (" %d", m);
                                              m++;
                           }
                           printf ("\n");
           }
           getch ( );
}



Click here to contact us

Loop control structure057

Write a program to construct  the image shown below.
                             1
                           232
                         34543
                       4567654
                     567898765


#include <stdio.h>
#include <conio.h>

void main ( )
{
            int          i, j, k, m = 1;
            clrscr ( );
                                               
            printf ("\n\t\t\t   Design of Numbers");
            printf ("\n\n\n");
                                      
            for ( i = 1; i <= 5; i++ )
            {                                     
                            for ( k = 35; k >= i; k-- )
                            {                                     
                                               printf (" ");
                            }                                       
                            for ( j = i; j <= m; j++)
                            {                                       
                                               printf ("%d", j);
                            }                       
                            for ( j = m - 1; j >= i; j-- )
                            {                                         
                                               printf ("%d", j);
                            }
                            m = m +2;
                            printf ("\n");
            }
            getch ( );
}



Click here to contact us

Tuesday, 21 August 2012

Loop control structure056

Write a program to construct  the image shown below.
                                1
                              11
                            101
                          1001
                        10001
                      100001
                    1000001
                  10000001
                  111111111


#include <stdio.h>
#include <conio.h>

void main ( )
{
           int            i, j, k;
           clrscr ( );
                                         
           printf ("\n\t\t\t   Design of Numbers");
           printf ("\n\n\n");
                                     
           for ( i = 1; i <= 9; i++ )
           {                                  
                           for ( k = 21; k >= i; k-- )
                           {                                        
                                              printf ("  ");
                           }                                     
                           for ( j = 1; j <= i; j++)
                           {                                    
                                           if ( i == 9 || j == 1 || j == i )
                                                            printf (" 1");
                                           else                                   
                                                            printf (" 0");
                           }
                           printf ("\n");
           }
           getch ( );
}



Click here to contact us
Related Posts Plugin for WordPress, Blogger...