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");
}
}
Output:
ABCDEFGHGFEDCBA
ABCDEFGGFEDCBA
ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA
#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");
}
}
How to print the rohmbus pattern code in c?
ReplyDeletecan you help me.