473,322 Members | 1,232 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,322 software developers and data experts.

Program that diplays corresponding ASCII code for the numbers 0-127, 16 per line.

this continue to stop at 10 and 13. Need Help!
Expand|Select|Wrap|Line Numbers
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  char k;
  7.  for(int i=0; i<127; i++)
  8. {
  9. cout << (char)i;
  10. k= (i+1)%16;
  11. if (k == 0)
  12. cout << "\n";
  13.  
  14. }
  15.  cout << "\n";
  16.     return 0;
  17.     }
  18.  
Apr 8 '08 #1
5 872
This is the output that it gives.
☺☻♥♦♣
♫☼
►◄↕‼¶§▬↨↑↓→←∟↔▲▼
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~
Apr 8 '08 #2
Laharl
849 Expert 512MB
Please only create one thread per problem. If you're having issues with getting responses, post in the thread yourself (after a day or so with no help) rather than creating a new one. To answer your question, are you familiar with if statements?
Apr 8 '08 #3
yes i am famililar with if statements
Apr 8 '08 #4
i would like to know why it stops at 10 and 13
Apr 8 '08 #5
Laharl
849 Expert 512MB
It stops at 10 and 13 because those are LF and CR (line feed and carriage return). These are printed as newlines because in files, rather than using the \n newline character, OSs use LF+CR or CR to mark the end of a line. For more information, Wikipedia. Thus, if you want 16 characters per line, you'll need to replace printing these with printing some other form of whitespace.
Apr 8 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Ling Lee | last post by:
Hello. I'm trying to write a small program that lets you put in a number as an integer and then it tells you the textuel representation of the number. Like if your input is 42, it will say...
8
by: sugaray | last post by:
hi, i wrote a simple base-conveter utility for practice, it seems works fine right now, hope any gurus out there can give me some suggestions to, critics of, optimisations on this program or my...
10
by: Robert Rotstein | last post by:
Following is a C program, taken from http://en.wikipedia.org/wiki/Quine#Sample_quine_in_C, which has the curious property that, when executed, it produces its own source code as output. ...
1
by: Willing 2 Learn | last post by:
Below is a program I did to recognize a Finite State Automata for ASCII (J+H)*. I got that one working but im having trouble getting the NFA program to work. I really desperately need help! My...
19
by: many_years_after | last post by:
Hi,everyone: Have you any ideas? Say whatever you know about this. thanks.
1
by: irfath | last post by:
Write an interactive program that reads three (3) lists of numbers, which are stored in three separate files, and creates one (1) sorted list. Each file should contain not more than 15 numbers....
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...
2
by: aminnfs | last post by:
Write a program that reads in a character from the keyboard, and then displays one of the following messages: if <char> is a lower case letter, the message "The upper case character...
0
by: yabighelen | last post by:
HELP!!!!! I have to write a program that does this: Create a program that encrypts and decrypts a message... Inputs: A typed message Output: When the encrypt button is clicked the input...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.