Reply
Old 06-05-2014, 06:06 AM   #1 (permalink)
 
Status: Junior Member
Posts: 5



Default computer science help

how do i solve this? i've been working on this for hours..



Execute the following program and show its output for the input value 15:
#include <iostream>
using namespace std;
int gnum1, gnum2;

void funct(void)
{
int num = 2 * gnum1 + 5;
gnum2 = gnum1 + num;
gnum1 = gnum2 + 10;
}

int main( )
{
gnum1 = 25;
funct( );
cout << endl << “gnum1=” << gnum1 << “\tgnum2=” << gnum2;
cin >> gnum1;
funct( );
cout << endl << “gnum1=” << gnum1 << “\tgnum2=” << gnum2;
return 0;
}
newyorkzfinestladi06 is offline   Reply With Quote
Old 06-05-2014, 06:06 AM   #2 (permalink)
 
Status: Junior Member
Posts: 3



Default computer science help

Put this code into a C++ file and compile it into an executable program. When you execute this program in your console, it should first print out

gnum1=90 gnum2=80

and then because of "cin" you'll be prompted to input a value (presumably you want 15) for gnum1, after which the program should print out

gnum1=60 gnum2=50
PiRhoTeXNiX is offline   Reply With Quote
more..
Old 06-05-2014, 06:06 AM   #3 (permalink)
 
Status: Senior Member
Posts: 2,787



Default computer science help

The first instruction is:
>>> "Execute the following program"

Are you saying you do not know how to execute a program?

>>> "for the input value 15"

Are you saying you do not know how to supply an input of 15 to program?

>>> "show its output"

Are you saying you don't know how to identify what is "output"?

or are you saying that you can identify it but you don't know how to "show" it?

>>> "how do i solve this?"

What is there to "solve"?

>>> "i've been working on this for hours.. "

Does "working on this" mean you've been staring at it without actually doing anything?

>>> "what is your email?"

There is no need for that. You can add additional details in this question.
EddieJ is offline   Reply With Quote
Old 06-05-2014, 06:06 AM   #4 (permalink)
 
Status: Senior Member
Posts: 719



Default computer science help

Dude, can you post the rest of the question up here, so I can understand it a little bit more. Based on the information above, I have no idea what you're talking about.

"Execute the following program" OK, we all need to execute it after finish the coding part.

"show its output for the input value 15" What the hell is this really mean? What chapter are you on? Does it has to pass through any loop, array or just output "15"? or output 1-15?
Money07 is offline   Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
I am not sure weather to pursue a bachelors in Computer Science or Computer Science Information Systems? MysteriousSecret Computer Programmer 2 06-20-2014 10:06 AM
Is computer science hard? Can a software engineer be good at math but not much in computer science? Kaivon Software Engineers 1 07-12-2013 06:05 AM
Good ideas for Computer Science job searching or Computer Science-related independent projects? AngeloRivera Developer/ Developers 2 06-11-2013 02:05 AM
Are there benefits in majoring in computer science over information science? Hitler Computer Programming 1 03-28-2013 10:02 PM
How much math is involved in Computer Science? What would I learn in Computer Science? Unknown_User Html Code/ Html Codes 1 07-07-2012 10:37 AM