Tuesday, November 25, 2025

Write the C Program. Print the following format (Numbers in K Type)

 

     12345
    1234
    123
    12
    1
    1
    12
    123
    1234
    12345

#include<stdio.h>
main( )
{
    int i,j;
    for(i=5;i>=1;--i)
    {
for(j=1;j<=i;++j)
           printf("%2d",j);
        printf("\n");
    } 
    for(i=1;i<=5;++i)
    {
        for(j=1;j<=i;++j)
           printf("%2d",j);
        printf("\n");
    }
}


            Output




Write the C Program. Print the following format


    1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 14 15


#include<stdio.h>
main( )
{
    int i,j,k=1;
    for(i=1;i<=5;++i)
    {
for(j=1;j<=i;++j)
{
   printf("%3d",k);
   ++k;
}
        printf("\n");
    }
}


            Output

            


Write the C Program. Print the following format

 Write the C Program. Print the following format  

    *****
    ****
    ***
    **
    *


#include<stdio.h>
main( )
{
    int i,j;
    for(i=5;i>=1;--i)
    {
for(j=i;j>=1;--j)
   printf("*");
        printf("\n");
    }
}


                    Output




Write the C Program. Print the following format

 

Write the C Program. Print the following format  

5 4 3 2 1    
4 3 2 1     
3 2 1      
2 1       
1        




#include<stdio.h>
main( )
{
    int i,j;
    for(i=5;i>=1;--i)
    {
for(j=i;j>=1;--j)
           printf("%2d",j);
        printf("\n");
    }
}


        Output

    




Write the C Program. Print the following format

 Write the C Program. Print the following format  

    1
    12
    123
    1234
    12345


     
     


#include<stdio.h>
main( )
{
    int i,j;
    for(i=1;i<=5;++i)
    {
        for(j=1;j<=i;++j)
           printf("%2d",j);
        printf("\n");
    }
}

            Output



Monday, November 24, 2025

Write the C Program. Print the following format

 Write the Program Print the following format
        12345        
        12345       
        12345       
        12345       
        12345 


#include<stdio.h>
main()
{
    int i,j;
    for(i=1;i<=5;++i)
    {
          for(j=1;j<=5;++j)
       printf("%2d",j);
          printf("\n");
    }
}

                       Output



Fibonacci Sequence up to 10

 First few numbers: 0,1,1,2,3,5,8,13,21,34


Sequence and Formula:

The sequence starts with f=0 &  f1=1             

 Every subsequent number is by adding the two numbers before it.

f2= 0+1 -> 1  1+1 ->2  1+2 -> 3 ........


   f2=f1+f        
   f=f1 
   f1=f2







 #include<stdio.h>
main()
{
       int f=0,f1=1,f2=0,i;
       printf("\n%d\t%d",f,f1);
       for(i=3;i<=10;++i)
      {
            f2=f1+f;
            printf("\t%d",f2);
            f=f1;
            f1=f2;
      }
}


Output