Home › Forums › C Programming › Need help URGENTLY on my assignment (instructions inside)
- This topic has 1 reply, 2 voices, and was last updated 15 years, 7 months ago by GWILouisaxwzkla.
- AuthorPosts
- March 14, 2009 at 10:41 am #2180QQOHallalnzkmwhParticipant
hi im new to the forums as u can tell..
ive been reading c++ coding since last week and i’ve just got an assignment from my uni.. im really stuck on what to do..
as i say.. i suck at coding.. its not my forte but i must do it to pass my course :S
could sum1 please code this for me, i kno it sounds stupid but i really do need help on this.. i’d b very grateful is sum1 could. so that way i can read it and get a better understanding of what i was supposed to do.
im supposed to do the following:
In this program you will first create a string that has the exact content “Hello World.” The command line should have no parameters. The following text lists errors you must detect and a priority of testing. All outputs are a single character followed by a linefeed ( endl in C++ or n in C).
– If there is more than one parameter the output shall be ‘P’.
– If the parameter is not an integer the output shall be ‘X’.
– The input integer is an index into the string where [0]=’H’,[1]=’e’, [2]=’l’ etc. (to make up Hello World) Your program should return the letter pointed to by the number then a linefeed.
– If the number is not within the string the reply must be ‘Z’.so basically your reading from command line and have to process them to produce the output. im supposed to also ouput how many arguments there are. for example ./myoutput 123 435 would b “3” arguments “./myoutput “01234” ” would show 2 arguments and print out “Hello” ( 01234 part of Hello World, 0 = H, 1 = e and so on). minus signs, character letters etc should output with the letter X.
i kno wut im supposed to b doing.. its just the coding that i dont know. please dont giv me any trouble over this.. im stressed out enough as it is :S. i jus need sum1 to help me code this.. id b very grateful if any1 can do this for me. i have to hav it done by 16th march on monday so ive basically got tomorrow (sunday) to complete this :S
- March 16, 2009 at 8:40 pm #3523GWILouisaxwzklaParticipant
Not totally sure what you need ( not sure what the ‘p’ condition should be ) but heres a start:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253<br /><br />/****************************************************************<br />* File Name : c:programstempCG.cpp<br />* Date : March,16,2009<br />* Comments : new project<br />* Compiler/Assembler :<br />* Modifications :<br />*<br />*<br />*<br />*<br />*<br />* Program Shell Generated At: 3:34:03 p.m.<br />=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /><br /><br />#include <br />//#include <br />//#include <br />//#include <br />//#include <br />//#include <br /><br />using namespace std;<br /><br />//main function ******************************<br /><br />int main ( )<br />{<br /><br />char hello [ 12 ] = "Hello world";<br />char ch;<br />char newline = 10;<br /><br />cout < ";<br />ch = cin.get();<br />while ( ch != newline )<br />{<br /><br /><br />if ( ch > 0 && ch < 0 )<br />cout << "x" << endl;<br />else if ( ch - '0' >= 0 && ch - '0' <= 11 )<br />cout << hello [ ch - '0' ] << endl;<br />else if ( ch - '0' 11 )<br />cout << "z" << endl;<br />ch = cin.get();<br />}<br />return 0 ;<br />}<br /><br />
- AuthorPosts
- The forum ‘C Programming’ is closed to new topics and replies.