473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ASCII Code???

i couldnt figure out how i am supposed to find the ASCII code is there
any way to do it? and main problem is i am not sure so i wanted to ask
is it going to display 'a' ? am i right?
What is the ASCII code displayed by the cout at Line 19?
12 char f1(char a) {
13 if (a < 'a') return a;
14 else f1(a - 1);
15 } // end f1
16 int main (int argc, char **argv)
17 {
18 char reply;
19 cout << (int)f1('a') << endl;

please help me out!!!!!

Mar 23 '07 #1
8 2308
ia*************@gmail.com wrote:
i couldnt figure out how i am supposed to find the ASCII code is there
any way to do it? and main problem is i am not sure so i wanted to ask
is it going to display 'a' ? am i right?
What is the ASCII code displayed by the cout at Line 19?
12 char f1(char a) {
13 if (a < 'a') return a;
14 else f1(a - 1);
15 } // end f1
16 int main (int argc, char **argv)
17 {
18 char reply;
19 cout << (int)f1('a') << endl;

please help me out!!!!!
Did you try it?

--
Ian Collins.
Mar 23 '07 #2
did i try what i have this much of the code i cannot compile it so i
am trying to understand by reading the code and my understanding it
should be'a' displayed. What i am asking is am i right or not?

Mar 23 '07 #3
ia*************@gmail.com wrote:
did i try what i have this much of the code i cannot compile it so i
am trying to understand by reading the code and my understanding it
should be'a' displayed. What i am asking is am i right or not?
Please keep the context you are replying to.

Why couldn't you compile it, perhaps if we help you with that, you can
run your own tests.

By the way, it can't output 'a' because you have cast the result to int.

--
Ian Collins.
Mar 23 '07 #4
On Mar 22, 6:41 pm, Ian Collins <ian-n...@hotmail.comwrote:
ianenis.tiry...@gmail.com wrote:
did i try what i have this much of the code i cannot compile it so i
am trying to understand by reading the code and my understanding it
should be'a' displayed. What i am asking is am i right or not?

Please keep the context you are replying to.

Why couldn't you compile it, perhaps if we help you with that, you can
run your own tests.

By the way, it can't output 'a' because you have cast the result to int.

--
Ian Collins.
no what i mean if it is 'a' it should pump out the ASCII code for the
variable right? but so that what you are saying it cannot be a's ASCII
code right?

the thing is this code is not to compile it is and extra credit for me
and this is really what i am supposed to do. if you look at it it
wouldnt even work if you run the program i guess. -at lest not with
the info given -

Mar 23 '07 #5
ia*************@gmail.com wrote:
On Mar 22, 6:41 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>ianenis.tiry...@gmail.com wrote:
>>>did i try what i have this much of the code i cannot compile it so i
am trying to understand by reading the code and my understanding it
should be'a' displayed. What i am asking is am i right or not?

Please keep the context you are replying to.

Why couldn't you compile it, perhaps if we help you with that, you can
run your own tests.

By the way, it can't output 'a' because you have cast the result to int.
*Please* don't quote signatures.
>
no what i mean if it is 'a' it should pump out the ASCII code for the
variable right? but so that what you are saying it cannot be a's ASCII
code right?
Ah, I see now. Sorry I though you where looking for 'a' as the output,
not its ASCII value.

As written the code will not output the ASCII value for 'a'. I think
calling f1's parameter a is causing confusion. Look at the else branch,
what is being returned from it? What happens when the input is 'a'?

Another thing, don't use <iostream.h>, the correct header is <iostream>.
the thing is this code is not to compile it is and extra credit for me
and this is really what i am supposed to do. if you look at it it
wouldnt even work if you run the program i guess. -at lest not with
the info given -
No, it won't.

--
Ian Collins.
Mar 23 '07 #6
On Mar 22, 7:04 pm, Ian Collins <ian-n...@hotmail.comwrote:
ianenis.tiry...@gmail.com wrote:
On Mar 22, 6:41 pm, Ian Collins <ian-n...@hotmail.comwrote:
>ianenis.tiry...@gmail.com wrote:
>>did i try what i have this much of the code i cannot compile it so i
am trying to understand by reading the code and my understanding it
should be'a' displayed. What i am asking is am i right or not?
>Please keep the context you are replying to.
>Why couldn't you compile it, perhaps if we help you with that, you can
run your own tests.
>By the way, it can't output 'a' because you have cast the result to int.

*Please* don't quote signatures.
no what i mean if it is 'a' it should pump out the ASCII code for the
variable right? but so that what you are saying it cannot be a's ASCII
code right?

Ah, I see now. Sorry I though you where looking for 'a' as the output,
not its ASCII value.

As written the code will not output the ASCII value for 'a'. I think
calling f1's parameter a is causing confusion. Look at the else branch,
what is being returned from it? What happens when the input is 'a'?

Another thing, don't use <iostream.h>, the correct header is <iostream>.
the thing is this code is not to compile it is and extra credit for me
and this is really what i am supposed to do. if you look at it it
wouldnt even work if you run the program i guess. -at lest not with
the info given -

No, it won't.

--
Ian Collins.- Hide quoted text -

- Show quoted text -
ok thats the thing because when input is 'a' then it returns 'a' but
else it returns 'a-1' so there should be two different outputs
right? but the question asks ASCII code displayed by the line 19 so i
am really confused?

Mar 23 '07 #7
ia*************@gmail.com wrote:
>>
>>>the thing is this code is not to compile it is and extra credit for me
and this is really what i am supposed to do. if you look at it it
wouldnt even work if you run the program i guess. -at lest not with
the info given -

No, it won't.
*Please* don't quote signatures - that's the bit after the "-- ".
>
ok thats the thing because when input is 'a' then it returns 'a' but
else it returns 'a-1' so there should be two different outputs
right? but the question asks ASCII code displayed by the line 19 so i
am really confused?
Putting back your original code:

12 char f1(char a) {
13 if (a < 'a') return a;

This returns a when a is less than 'a'.

14 else f1(a - 1);

This doesn't return anything.

15 } // end f1
16 int main (int argc, char **argv)
17 {
18 char reply;
19 cout << (int)f1('a') << endl;

The output is undefined.

--
Ian Collins.
Mar 23 '07 #8

<ia*************@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
>i couldnt figure out how i am supposed to find the ASCII code is there
any way to do it? and main problem is i am not sure so i wanted to ask
is it going to display 'a' ? am i right?
What is the ASCII code displayed by the cout at Line 19?
12 char f1(char a) {
13 if (a < 'a') return a;
14 else f1(a - 1);
malformed code. Not all control paths of f1 return a value.

Was this supposed to be
else
return f1(a-1);
???
15 } // end f1
16 int main (int argc, char **argv)
17 {
18 char reply;
19 cout << (int)f1('a') << endl;

please help me out!!!!!

Mar 23 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
2
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program...
11
by: Kai Bohli | last post by:
Hi all ! I need to translate a string to Ascii and return a string again. The code below dosen't work for Ascii (Superset) codes above 127. Any help are greatly appreciated. protected...
18
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
10
by: Mark Rae | last post by:
Hi, I'm in the process if converting the data out of an old DOS-based SunAccounts system (don't ask!) into SQL Server. The data has been sent to me as a collection of hundreds of SunAccounts...
9
by: pamelafluente | last post by:
I have found on the web a post with this useful way to convert (if possible) a ScanCode to Ascii. This is remarkably useful to filter keys under KeyDown/up event. My problem is that I am not...
31
by: Claude Yih | last post by:
Hi, everyone. I got a question. How can I identify whether a file is a binary file or an ascii text file? For instance, I wrote a piece of code and saved as "Test.c". I knew it was an ascii text...
7
by: Jeffrey Spoon | last post by:
Hello, I'm a bit stuck trying to convert a text file which contains extended ASCII text and changing the ASCII values so they become readable. I do this by subtracting 127 from the ASCII value....
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
9
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.