Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    [solved](.cpp)"Hello world" in n900 (getting error) plz guide me.

    Reply
    Page 4 of 4 | Prev |   2     3   4 |
    onethreealpha | # 31 | 2011-06-17, 11:08 | Report

    Good beginners website HERE if you're interested in C++

    i found it great when I started learning C++

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to onethreealpha For This Useful Post:
    nicholes

     
    nicholes | # 32 | 2011-06-17, 11:21 | Report

    Originally Posted by demolition View Post
    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.
    well since my teacher is teaching me only C not C++ for now and,i have been told to learn C before starting c++ to learn basics of codes etc. so i would programme under C only for now but later i would expand....

    also my problem is solved by execute the .cpp so i changed the thread title by "[solved]" and for small questions i don't want to start a new thread and become a part of spam!!(no offence plz)

    again Thanks to all of you!

    Edit | Forward | Quote | Quick Reply | Thanks

     
    lfcobra | # 33 | 2011-06-17, 11:22 | Report

    Originally Posted by nicholes View Post
    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");
    }
    just a quick couple of tips. As previously stated try to use the actual c++ functions instead of the c funtions. They will make the code much easier to read, and also avoid unnecessary code complexity with unneeded nesting

    Code:
    #include <iostream.h>	
    #include <stdio.h>
    
    int main(){
    using namespace std;
    int s; //salary
    
    cout << "Enter your salary: " ;
    cin >> s;
    
    if (s>=5000)
       cout << "Your bonus is 500";
    else if (s>=3000)
       cout << "Your bonus is 300";
    else if (s>=1000)
       cout << "Your bonus is 100";
    else
       cout << "No bonus";
    getchar();
    
    return 0;
    }
    note: this code should work but i didnt get a chance to compile it.

    edit: just saw your post about being taught C so you can disregard my comment about using c++ functions

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by lfcobra; 2011-06-17 at 11:46.

     
    SubCore | # 34 | 2011-07-08, 17:34 | Report

    Originally Posted by nicholes View Post
    i have been told to learn C before starting c++ to learn basics of codes etc
    that's not a good idea. it's a waste of time actually: Should I learn C before I learn OO/C++?

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to SubCore For This Useful Post:
    geneven

     
    Page 4 of 4 | Prev |   2     3   4 |
vBulletin® Version 3.8.8
Normal Logout