To print the next character accepted from the user;
#include
int main()
{
char a,b;
printf("Enter any character: ");
a= getchar();
int c=a;
int d=c+1;
printf("The alterante of character user entered is ");
b= putchar(d);
printf("\n");
return 0;
}
|
Print next character
To compile this program in Linux:
- Save this file with extension .c
- g++ compiler come pre installed in linux. Type this in terminal g++ alternate.c -o alternate. Here, I have assumed that the file name is alternate.c. -o array will provide me with an output file with extension exe file and name alternate.
- Now, run this file typing ./alternate and press enter.
To compile this program using cmd:
- Save this file with extension.c
- Type this in the cmd g++ alternate.c -o alternate.
- To run type alternate and press enter.
Note: To use g++ compiler in windows user has to install these compiler by itself as g++ compiler does not come per installed in windows operating system.
|
No comments:
Post a Comment