Need little help {newbie)

This is a discussion on Need little help {newbie) within the C++ Programming forums, part of the General Programming Boards category; a)assigne the sum of x and y to z and increment the value of x by 1 after calculation b)Test ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    18

    Need little help {newbie)

    a)assigne the sum of x and y to z and increment the value of x by 1 after calculation
    b)Test if the value of the varaible count is greater then 10.if it is ,print ”count is greater then 10”.
    c)Decrement the varable x by 1 then subtract it from the varable total
    d)Calculate the remainder after q is divided by divisor and assign the result to q,Write this statement in two different ways.


    These are some question with which i need some help , about the part (b) it will be done just comparing the value of variable with 10 and if its greater then i should just print it rite?

  2. #2
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by Ahmed29 View Post
    a)assigne the sum of x and y to z and increment the value of x by 1 after calculation
    b)Test if the value of the varaible count is greater then 10.if it is ,print ”count is greater then 10”.
    c)Decrement the varable x by 1 then subtract it from the varable total
    d)Calculate the remainder after q is divided by divisor and assign the result to q,Write this statement in two different ways.


    These are some question with which i need some help , about the part (b) it will be done just comparing the value of variable with 10 and if its greater then i should just print it rite?
    It's correct, though you're just paraphrasing the question. What exactly are you having trouble with?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    18
    if u can code the other 3 parts i am having problem with cause i cant seem to write them

  4. #4
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by Ahmed29 View Post
    if u can code the other 3 parts i am having problem with cause i cant seem to write them
    are you a newbi programmer ? or you have difficulties understand what the question is about , and what are the requirments by the question?!

  5. #5
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Quote Originally Posted by Ahmed29 View Post
    a)assigne the sum of x and y to z and increment the value of x by 1 after calculation
    b)Test if the value of the varaible count is greater then 10.if it is ,print ”count is greater then 10”.
    c)Decrement the varable x by 1 then subtract it from the varable total
    d)Calculate the remainder after q is divided by divisor and assign the result to q,Write this statement in two different ways.
    A: You should have 3 integers named x, y and z. Basically you need to add the x and y integers together and assign them to the integer variable z in a statement, then after that statement increase the integer x by 1. You would do this using the addition operator (+). An example would be (Not exactly the same, you need to do SOME of the work lol, just a helper):

    Code:
    int a = 2;
    int b = 4;
    int c = 0;
    
    c = a * b;
    a++; // ++ is short for a = a + 1;
    B: You were correct with this one, you would do an if statement to check the value of the variable count like so:

    Code:
    if (count > a number) {
       do something
    }
    C: Decrement means to subtract 1 off the current value. It's the opposite of the ++ operator. An example:

    [code]
    y--; // this is short for y = y - 1;
    total -= y; // this is short for total = total - y;

    Q: Basically it wants you to use the modulus operator (&#37. This is used for getting the remainder of a number. It then wants you to assign the results to the variable q, and write it in two different ways. You can use a short hand way (like the ones I've been using) and the long hand way (like the ones in the comments), an example of modulus:

    Code:
    int remainder = number % 2; // remainder is now equal to the remainder of number divided by 2
    NOTE: You may want to cast a variable you're using with modulus into a double for a more accurate result.
    Last edited by pobri19; 10-29-2008 at 05:34 AM.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,772
    Do not hand out solutions to newbies. It will teach them nothing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    18
    Ok I have made three programs tell me if I am wrong with any (:

    Code:
    int main()
    {
    int x,y,z;
    clrscr();
    cout<<"\n Enter Value of x : ";
    cin>>x;
    cout<<"\n Enter Value of y : ";
    cin>>y;
    z=x+y;
    cout<<"\n Sum : "<<z;
    x=x+1;
    cout<<"\n Increment : "<<x;
    getch();
    return 0;
    }
    Code:
    int main()
    {
    int vcount;
    cout<<"\n Enter Value : ";
    cin>>cvount;
    if(vcount<10)
    cout<<"\n count is greater then 10 ";
    else
    cout<<"\n End ";
    getch();
    }

    Code:
    int main()
    {
    int x,sub;
    clrscr();
    cout<<"\n Enter Value of x : ";
    cin>>x;
    x=x-1;
    cout<<"\n decrement : "<<x;
    {
    sub=x-(x-1);
    cout<<"\n Sub from variable total : "<<sub;
    }
    getch();
    return 0;
    }
    And I really dont understand the last one, someone please explain it in detail..

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,772
    Indent your code. You cannot possibly expect us to read that unreadable code mess.
    That mentioned, the first is correct. The second has a logic error, and I do not understand the "subtract it from the varable total" part of the 3rd question.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    18
    Sorry for "subtract it from the varable total" il change that output statement. And whats the logical error in ques 2 :$

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Ahmed29 View Post
    Sorry for "subtract it from the varable total" il change that output statement. And whats the logical error in ques 2 :$
    if(vcount<10)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 06:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 11:53 AM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 11:27 AM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21