Urgent help about my code....

I

ianenis.tiryaki

i have thiscode and i have to figure out what character would be
displayed at line 23 but they are using this f1 functin so i am
confused.... please help me which character would be displayed?


12 char f1(char a) {
13 if(a < 'a') return a + ('a' - 'A');
14 else return a;
15 } // end f1
16 char f1(int a) {
17 if(a < 'a') return a;
18 else return a - ('a' - 'A');
19 } // end f1
20 int main (int argc, char **argv)
21 {
22 char reply;
23 cout << f1('M'+1) << endl;
 
I

Ian Collins

i have thiscode and i have to figure out what character would be
displayed at line 23 but they are using this f1 functin so i am
confused.... please help me which character would be displayed?
Have you tried it?

12 char f1(char a) {
13 if(a < 'a') return a + ('a' - 'A');
14 else return a;
15 } // end f1
16 char f1(int a) {
17 if(a < 'a') return a;
18 else return a - ('a' - 'A');
19 } // end f1
20 int main (int argc, char **argv)
21 {
22 char reply;
23 cout << f1('M'+1) << endl;
 
D

Daniel T.

i have thiscode and i have to figure out what character would be
displayed at line 23 but they are using this f1 functin so i am
confused...

Compile and run it...
please help me which character would be displayed?


12 char f1(char a) {
13 if(a < 'a') return a + ('a' - 'A');
14 else return a;
15 } // end f1
16 char f1(int a) {
17 if(a < 'a') return a;
18 else return a - ('a' - 'A');
19 } // end f1
20 int main (int argc, char **argv)
21 {
22 char reply;
23 cout << f1('M'+1) << endl;

"They" are outputing the result of the function call when 'M' + 1 is
passed in is 'M' + 1 < 'a'? if it is, then the function returns ('M' +
1) + ('a' - 'A'), otherwise it returns 'M' + 1.
 
I

ianenis.tiryaki

so mainly i need to say if it is smaller than 'a' then it is displayed
as ('M' +
 
Z

Ziyan

i have thiscode and i have to figure out what character would be
displayed at line 23 but they are using this f1 functin so i am
confused.... please help me which character would be displayed?

12 char f1(char a) {
13 if(a < 'a') return a + ('a' - 'A');
14 else return a;
15 } // end f1
16 char f1(int a) {
17 if(a < 'a') return a;
18 else return a - ('a' - 'A');
19 } // end f1
20 int main (int argc, char **argv)
21 {
22 char reply;
23 cout << f1('M'+1) << endl;

I think it's an 'n'.
'M' + 1 = 'N'
'N' is < 'a';
so 'N' + 'a' - 'A' = 'n'
 
C

carlmuller

i have thiscode and i have to figure out what character would be
displayed at line 23 but they are using this f1 functin so i am
confused.... please help me which character would be displayed?

12 char f1(char a) {
13 if(a < 'a') return a + ('a' - 'A');
14 else return a;
15 } // end f1
16 char f1(int a) {
17 if(a < 'a') return a;
18 else return a - ('a' - 'A');
19 } // end f1
20 int main (int argc, char **argv)
21 {
22 char reply;
23 cout << f1('M'+1) << endl;

The answer is implementation defined, i.e. it depends on which
computer/operating system you run it on.
If the operating system uses EBCDIC (e.g. IBM AS/400 computers), then
a different output will occur than if the system uses the ASCII
system.
I have not tested it but it looks like it will output the "RES ENP"
control character.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Python code problem 2
URGENT 1
Help with my responsive home page 2
ASCII Code??? 8
Help with code 0
problem with my code..... 12
Problem with codewars. 5
Help with code plsss 0

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top