Pages

Wednesday, December 30, 2020

C program to print Z to A using for loop

C Program to print Z to A using for loop


Program Code 1:

#include<stdio.h>
int main()
{
  int i;
  for(i='Z'; i>='A'; i--)
    printf("%c", i);
  
  return 0;
}

Output of the program:

ZYXWVUTSRQPONMLKJIHGFEDCBA

* * * * *

Same program can also be generated using following code.

Program Code 2:

#include<stdio.h>
int main()
{
    int i;
    //90 is ASCII value of Z
    for(i=90; i>=65; i--)
        printf("%c", i);
    
    return 0;
}

Output of the program:

ZYXWVUTSRQPONMLKJIHGFEDCBA

* * * * *



No comments:

Post a Comment