In this tutorial you will learn about the C Program to Print Next Successive Character and its application with practical example.
C Program to Print Next Successive Character
In this tutorial, we will learn to create a C program that will Print the Next Successive Character in C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional statements in c programming.
- String functions of c programming.
Program to Print Next Successive Character
As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First, we will take the input character from the user then we will Print the Next Successive Character. The ASCII value of the input character will be scanned and increased by 1 and print the character value.
With the help of this program, we can Print the Next Successive Character.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declare the variables for the program. 2. Take the input letter or character from the user. 3. Find the ASCII value of that number. 4. Addind that value by 1. 5. Printing the next character using the conditional statement. 6. End the program. |
Program to Sort Word in String in Ascending Order:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include<stdio.h> int main() { //declaring the variables for the program char ch; //Taking the input character from the user printf("Enter any character: "); //Scanning the input provided from the user scanf("%c", &ch); //printing the successor of that character printf("\n"); if(ch>=65 && ch<90) printf("%c", ch+1); else if(ch>=97 && ch<122) printf("%c", ch+1); else if(ch==90) printf("%c", 65); else if(ch==122) printf("%c", 122); else printf("%c", ch); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- ch = it will hold the character value for the input.
Input character message and Scan the character from the user.
Getting the ASCII value and calculating the next letter using the conditional statement.
And printing the output character.