![]() |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
These will work. Simple way (but might not be visible) Code:
#include <iostream> // use correct i.e. C++ library Code:
#include <iostream> // use correct i.e. C++ library |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
1 Attachment(s)
Quote:
since i am very very new in coding so i want to know what to type in xterminal after this (see image) i have got a.out in home/ user/ (see my first post to know what i have installed on n900 to run .cpp) (i myself not clear what i have done! lol) |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
Code:
chmod +x a.out Code:
./a.out |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
hello world apeared thanks to all CHEERS!!!!!!!!:) |
Re: [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.
Not being a real C or C++ programmer, should the logic of the program not be something like:
While no user input -> Hello World. :confused: |
Re: [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
The entry point of a C++ programme is main(), or pseudo-name thereof. The first command in main(), for this programme, is to stream a string to the standard output (console). The next is to return i.e. to end. In more complex programmes one might want {while(no user input){action}}, but here it's really simple. The other reason for saying No is in C++ while is a loop, so your logic would produce many, many "hello, world" s. However, only one is required. |
Re: [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
I do agree that the linear programming does the job probably with the smallest effort and tightest code. |
Re: [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.
1 Attachment(s)
One more qustion
#include <iostream> int main() { int s; //salry printf("enter your salary"); scanf ("%d",&s); if (s>=1000) { if (s>=3000) { if (s>=5000) printf ("your bonus is 500"); else printf("your bonus is300"); } else printf("your bonus is100"); } else printf("no bonus"); system("PAUSE"); } it execute and works perfact but sh:pause not found comes!! Any way to get rid of it |
Re: [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.
Now, you really need to stop using C standard functions, like printf and scanf. The C++ equivalents make the code easier to read and are *just as well implemented* in the STL (standard template library). C code will normally compile because C++ is a superset of C and some software, e.g. win32, hasn't been fully converted to C++ yet.
Next, as mentioned above, system("pause") doesn't work outside dos/windows. If your programme just runs and exits without you being able to see the output try my v2. It seems you are very new to programming overall - no worries and well done for giving it a go. Amongst other paradigms, Encapsulation and Abstraction are part of the bedrock of C++, as an OO language. In programming, encapsulation means wrapping functionality together. And, abstraction means removing or separating one bit of functionality from another. I will edit this post in a minute with the C++ version of your code. ps - any chance you can either start a new thread or remove the Solved if you've got more questions. Bit misleading otherwise. |
Re: [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.
Yeah I said this earlier. You're writing just plain C in a very procedural manner, I think you need to look for a better C++ resource, one that is aimed at linux or uses standard headers, operators and such.
You could learn C if you like, I would recommend it over C++, but if you're looking for a career in programming then stick with OO languages like Python, C++ or Java |
All times are GMT. The time now is 16:29. |
vBulletin® Version 3.8.8