-->
Showing posts with label alphabetical pattern. Show all posts
Showing posts with label alphabetical pattern. Show all posts

WAP to get following alphabetical pattern

/*WAP to get following

ABCDE
ABCD
ABC
AB
A
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=4;i>=0;i--)
{
  for(j=0;j<=i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-----------------
logic in mind
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so. 
for more: look down.
--------------
program screenshot:-



program output:-


to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-










to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");
  //a++;
}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-










to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-