Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- string s;
- cin>>s;
- s+="x"; //add x in string
- for(int i=0;i<s.size();i++){
- cout<<s[i]-'a'<<" "; //prints value equal to their ascii-97;
- // s[i] s like 'a','b';
- //if u r using 's[i]' the in realiy u r using ''s[i]'' ....because s[i]='a';
- cout<<int(s[i]-'a');
- if((s[i]-'a')>=0) //u can also use int(s[i]-'a');
- printf("neeraj ");
- }
- cout << int('a'); // prints value =97;
- char a='p';
- cout<<('p'-'a')<<" "; //prints asciii value of 'p'- ascii value of 'a';
- cout<<'z'-a<<" "; // print ascii value of 'z' - ascii value of 'p';
- if(a>0)
- printf("%d neeraj",a);
- cout<<a<<" "; //print p;
- cout<<'a'<<" "; //print a;
- cout<<int(a)<<" "; //prints ascii value of p;
- cout<<int('a')<<" "; //prints ascii value of a;
- return 0;
- }
Add Comment
Please, Sign In to add comment