MFIB - Alphabet Position in Reverse ID:10676


Fill in the blanks with code so that the program accepts an alphabet and prints the alphabet position in reverse.

Example Input/Output 1:
Input:
b

Output:
25

Example Input/Output 2:
Input:
z

Output:
1


import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char ch = sc.next().charAt(0);
System.out.print(26-((int)ch-97)); } }

Comments

  1. can u explain it in the from of c program

    ReplyDelete
    Replies
    1. #include
      int main(){
      char c;
      scanf("%c",&c);
      printf("%d",26-(c-97));
      }

      Delete

Post a Comment

Popular Posts