C Program to print English Alphabets between two Alphabets

Description

Get two alphabets and print the alphabets lies between them.
Input:
D H
Ouput:
D E F G H

Solution

#include<stdio.h>
int main()
{
	int i;
	char start,stop;
	printf("enter two alphabets:");
	scanf("%c %c",&start,&stop);
	for(i=start;i<=stop;i++)
	{
		printf("%c",i);
	}
	return 0;
}

Explanation

Instruction(s) inside the for block{} are executed repeatedly till  the second expression is true.

Here i is initialized to start and incremented by 1 for each iteration, instructions inside the for block are executed unless i becomes greater than stop. so value of i will be printed as character like d e f g h using printf statement and format specifier %c.



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution