Saturday, 17 February 2018

Print Alphabet Pattern In C


A                                                                                                                              
AB                                                                                                                             
ABC                                                                                                                            
ABCD                                                                                                                           
      

#include<stdio.h>
#include<conio.h>
void main()
{
 int i, j;
    for(i=1;i<=4;i++)
    {
      for(j=1;j<=i;j++)
      {
       printf("%c",'B' + j-1);
      }
      printf("\n");
    }
getch();
}


D                                                                                                                              
CD                                                                                                                             
BCD                                                                                                                            
ABCD 

#include<stdio.h>
#include<conio.h>
void main()
{
 int i, j;
    for(i=5;i>=1;i--)
    {
        for(j=i;j<=4;j++)
        {
            printf("%c",'A' + j-1);
        }
        printf("\n");
    }
getch();
}



A                                                                                                                              
BB                                                                                                                             
CCC                                                                                                                            
DDDD 

#include<stdio.h>
#include<conio.h>
void main()
{
int i, j;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
printf("%c",'A'-1 + i);
}
printf("\n");
}
getch();
}


AAAA                                                                                                                      
BBB                                                                                                                            
CC                                                                                                                             
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j;
for(i=1;i<=4;i++)
{
for(j=4;j>=i;j--)
{
printf("%c",'A'-1 + i);
}
printf("\n");
}
getch();
}


i                                                                                                                              
in                                                                                                                             
ind                                                                                                                            
indi                                                                                                                           
india 
       
#include<stdio.h>
#include<conio.h>
void main()
{
char s[]="india";
int i,j;
clrscr();
for(i=0;s[i];i++)
{
for(j=0;j<=i;j++)
printf("%c",s[j]);
printf("\n");
}
getch();
}

No comments:

Post a Comment

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...