1. ASCII values

hey, thanks for looking at my thread.
I am currently trying to find the ASCII value of my input. I can correctly get my program to display the ASCII value of one character, however I am wondering if it is possible to find the ASCII value of two character.

For example I know that C is 43 and K is 4b, however would there be a value for CK if they were combined?

thanks

2. No - they will never be "combined." They will always remain distinct values (0x43 and 0x4B, respectively, in this case).

3. The model used for ASCII is one code for one key on the (US) keyboard and hence one character. Two characters such as '^' and 'a' might be conceptually combined to produce the separate character 'â' but this character is not representable as ASCII.

4. ok thank you very much. Would it be possible to sort these ASCII values using bubble sort?

5. Sure. You can compare ASCII values because they are simply numbers. Or you can compare strings - groups of ASCII values and sort 'words'.

6. Originally Posted by SDH
ok thank you very much. Would it be possible to sort these ASCII values using bubble sort?
You should Google for ascii table, and download either a table, or a picture of a table, and keep it on your desktop for easy reference. It will have all the values (either basic ascii 0-127, or extended for unsigned char with values from 0-255.

Along with the char symbol, it will also have the octal, hexadecimal, and decimal values of each of the symbols (depending on what table or picture you choose).

And it's already sorted for you.

7. i am very new to programming, this is what i have been working on and trying to adapt one my lecturer showed me.

Code:
```{
int a, b, c;

for (a = (array_size - 1); i > 0; a--)
{
for (b = 1; b <= a; b++)
{
if (numbers[b-1] > numbers[b])
{
c = numbers[b-1];
numbers[b-1] = numbers[b];
numbers[b] = c;
}
}
}
}```
does this code look alright to use?

You should Google for ascii table, and download either a table, or a picture of a table, and keep it on your desktop for easy reference. It will have all the values (either basic ascii 0-127, or extended for unsigned char with values from 0-255.

Along with the char symbol, it will also have the octal, hexadecimal, and decimal values of each of the symbols (depending on what table or picture you choose).

And it's already sorted for you.
I am currently sitting with a few books open and one open to an ASCII table, but nice idea will print one out for my desk

9. Originally Posted by SDH
i am very new to programming, this is what i have been working on and trying to adapt one my lecturer showed me.
does this code look alright to use?
You can print up your own ascii table, sure. And your character set may be slightly different from the ones in the standard ascii table - especially above 127. You'll notice that the character set for forums will also be slightly different than your own - again, especially above 127.

Your code as it stands won't work, but I'll help you get one that will work, if you like.

Note that when you paste in code, paste it in as PLAIN TEXT, instead of colored. The forum will color the code properly, and give it a better font, etc. With the colors you posted, it's difficult to read.

10. thank you very much Adak, would really appreciate any help with the bubble sort. What is wrong the bubble sort I have posted, so I can learn from my mistakes.

Note that when you paste in code, paste it in as PLAIN TEXT, instead of colored. The forum will color the code properly, and give it a better font, etc. With the colors you posted, it's difficult to read.
thanks sorry for the hindrance.

11. i have had a look at my code again - simplified it down by using letters instead of words, will change them once I have got it working properly. however when I run it, it says there is a problem on line 16.
Code:
``` #include <stdio.h>
int main( void )
{
int numb[5];
int i,j;
int temp;

printf("enter 5 numbers\n", i);

for ( i=0;i<=4; i++)
scanf( "%d", &j);
{
for ( i=0; j<=3; i++)
{
if (j=i+1; j<=6; j++)
{
temp = numb[i];
numb[i] = numb[j];
numb[j] = temp;
}
}

}
}```

12. > for ( i=0; j<=3; i++)
> if (j=i+1; j<=6; j++)
You have 5 numbers, so where did 3 and 6 come from?

If you have
int array[N];

Then the usual form of the for loop is to write
for ( i = 0 ; i < N ; i++ )

Using <= and subtracting 1 from the dimension yourself just leads to confusion.

13. Typing out an entire program and hitting compile when you're done is guaranteed to cause massive headaches.

Tip 1: Compile often when writing code. This way, if you make a syntax error, you know it is likely be caused by something you recently added, narrowing the focus for troubleshooting. This will also encourage writing complete "skeleton" code (i.e. making sure all your loop brackets are in place) before filling in the details later on.

Tip 2: Break the problem into smaller, manageable problems, and solve them one by one. In your case, I'd follow these steps:

- Write a program that prints five numbers from an array to the screen
- Add code to receive numbers from the user before printing the array to the screen
- (For quick debugging, don't be afraid to put temporary print statements in your loops to see what your variables are doing)

The trick is to make sure each little piece is working as expected before moving on to the piece.

I'd also recommend reading the following link - I've echoed some of the message in this post, but it's a lot more clear to see visually.

A development process

14. Originally Posted by Matticus
No - they will never be "combined." They will always remain distinct values (0x43 and 0x4B, respectively, in this case).
The standard allows it, although the meaning is implementation defined:

Code:
`short int multiple = 'CK';`

15. Originally Posted by brewbuck
The standard allows it, although the meaning is implementation defined...
Though allowed by the standard, wouldn't such an example fall outside the scope of what is considered "ASCII" (as per the original question)? If so, then I should have been more clear with my original statement.