Click here to Skip to main content
15,889,600 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
The Problem is that i should be able to get an output of this "wrong" program in an online compiler, but i can not seem to make it work.
On the verge of giving up to find the solution so i thought i'd post the question here,

So basically, the program should manipulate the characters " Comp@uter! " using the isalpha() and isupper() function on C++ and give the proper output , so can someone please help me out, if not for running online can anyone give me an answer on this?

will be realy helpful if each line is explained after the 3rd line,

Please no hate, I'm not a computer programmer.


#include<iostream.h>
#include<ctype.h>
void main( )
{ char Text[ ] = "Comp@uter!";
for(int I=0; Text[I]!=‟\0‟;I++)
{ if(!isalpha(Text[I]))
Text[I]=‟*‟;
else if(isupper(Text[I]))
Text[I]=Text[I]+1;
else
Text[I] = Text[I+1]; }
cout<<Text; }


What I have tried:

Tried running online doesn't work
Posted
Updated 23-Feb-17 9:28am
v2
Comments
[no name] 23-Feb-17 14:59pm    
This is not a "problem" to solve.
Richard Deeming 23-Feb-17 15:05pm    
Looks like you've copied that code from a website without correcting the "smart" quotes.

Start by fixing that. Then, if it still doesn't work, click "Improve question" and update your question with a clear description of what the problem is and how you've tried to fix it. Include the full details of any errors, and remember to indicate which line of the code each error relates to.
Member 13020122 23-Feb-17 15:15pm    
Yes , i did that.
AnvilRanger 23-Feb-17 15:17pm    
Funny this looks exactly like a question that was posted yesterday, but tagged C#. Are you in the same class as that other user?
Member 13020122 23-Feb-17 15:21pm    
Lol, I guess so xD

1 solution

First thing, you need to learn how to format your code and use indentation, it really help for reading the code and understand it.
C++
#include<iostream.h>
#include<ctype.h>
void main( )
{
	char Text[ ] = "Comp@uter!";
	for(int I=0; Text[I]!=‟\0‟;I++)
	{
		if(!isalpha(Text[I]))
			Text[I]=‟*‟;
		else if(isupper(Text[I]))
			Text[I]=Text[I]+1;
		else
			Text[I] = Text[I+1];
	}
	cout<<Text;
}

Quote:
Please no hate, I'm not a computer programmer.

No hate here, we were all beginner once. If we don't just give the answer, it is because we know from experience that it is the worst thing to do, it don't help you to learn programming.

Quote:
Tried running online doesn't work

This is not informative, asking question is also a wanted skill. Try to give informations like error messages and positions.

Once compiler errors are corrected, you can use the debugger, it is a tool that will allow you to see the program executing.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 
v3
Comments
[no name] 23-Feb-17 15:29pm    
And fix the compilation errors.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900