### Help with a Lab C++

I have to do a lab for my intro to programming class and I was hoping you guys could help me get started?

Read the individual characters into a partially-filled array of char elements.
Stop reading characters when a ; is encountered.
Convert valid base-10 digits (i.e. 0 through 9) into the corresponding number. Ignore any comma (',') or period ('.') characters that may be present.
Print out the number.
Print out the number multiplied by 2. (This checks that you really did convert the number to an int and aren't just printing the digits back).

Example input/output

Enter digits: 1 2 3 4 ;
Number: 1234, multiplied by two: 2468
Enter digits: 4 , 1 0 9 ;
Number: 4109, multiplied by two: 8218
Enter digits: 1 . 2 3 1 ;
Number: 1231, multiplied by two: 2462
Enter digits: 0 ;
Press any key to continue...
here what you are looking for:
 ``123456789101112131415161718192021`` ``````#include #include using namespace std; int length(char e[]){ int s=0; for (int q=0;q<=100;q++) {if (e[q]==0) {s=q;break;}} return s;} void main(){ char x[32],m[32];int u,w,i;int y; cout<<"enter digits :"; cin>>m;i=0; while (m!=0){u=0;y=0; w=length(m); for (i=0;i>m;}}``````
Last edited on
Thanks, I actually had to use a switch statement, forgot to mention that, but here is my final code:
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283`` ``````#include using namespace std; int main() { char i; char d[10]; char n = 10; int value = 0; cout<<"Enter digits:"<>d[i]; if(d[i] == ';') break; } for (i=0; i
Topic archived. No new replies allowed.