Pattern Codes, ABCDE Code, Arduino Code

Friday, 13 January 2017

ABCDE pattern in c

Print ABCDE pattern in c

Output:

ABCDEFGHGFEDCBA
ABCDEFGGFEDCBA
ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA

Code:

#include<stdio.h>

int main()
{ int i,j,k;
char ch = 'A';
char n;
printf("\n Enter the charachter of  your choice");
scanf("%c",&n);
k = n;
for(i = ch ;i<= n; i++)
{ ch = 'A';
for(j=n; j>=i; j--)
{ printf("%c",ch);
ch++;
}
if(k==n)
{ ch--;
for(k = n-2;k>=j;k--)
{ch--;
printf("%c",ch);
}
}
else
{for(k = n-1;k>=j;k--)
{ch--;
printf("%c",ch);
}
}
printf("\n");
}
}

1 comment :

  1. How to print the rohmbus pattern code in c?
    can you help me.

    ReplyDelete

Rolls Royce

Rolls Royce
Amazing Cars

About Me