473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

computer problem...

Bigj0410
i was working on a couple program questions and apparently...my PC has a virus....so right now i'm on a friends PC where he doesn't have any C++ programs....so i was just wondering what are the outputs of these programs below...thx in advance ;)

(program 1)

char x[3] = {‘0’, ‘1’, ‘2’} ;
int y[3];
for (int i = 0 ; i < 3 ; i++)
{
y[i] = x[i] ;
cout << x[i] << "\t" <<y[i]<< endl;
}

(program 2)

#include <iostream>
using namespace std;
long int mystery(int, int);
int main()
{
int in1, in2;
cout << "Enter two integers: ";
cin>>in1>>in2;
cout <<"The result is " << mystery (in1, in2)<<endl;
return 0;
}
//parameter b must be a positive
long int mystery (int a, int b)
{
if (b==1)
return a;
else
return a + product(a, b-1);
}
Feb 22 '07 #1
5 1044
DeMan
1,806 1GB
Surely the idea is for you to step through the code and try to see if you can see what's going on?

The first one is very simple, have a think about what is being done. (The cout line is the one that does the printing./.....)

the key here is to follow the code through the method calls. I am assuming that product(int, int) is defined somewhere?......
Feb 22 '07 #2
Surely the idea is for you to step through the code and try to see if you can see what's going on?

The first one is very simple, have a think about what is being done. (The cout line is the one that does the printing./.....)

the key here is to follow the code through the method calls. I am assuming that product(int, int) is defined somewhere?......
yea...but i don't know where though
Feb 22 '07 #3
Ganon11
3,652 Expert 2GB
I have a feeling that the function call is supposed to be mystery(a, b-1) rather than product(a, b-1).
Feb 22 '07 #4
I have a feeling that the function call is supposed to be mystery(a, b-1) rather than product(a, b-1).
...ok....right now my PC is getting checked...thx 4 da info
Feb 22 '07 #5
ok...now it works
Feb 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: anton.vredegoor | last post by:
Here's my situation: I'm typing this in a public library on a computer with OS windows 2000 server. I can run Internet explorer, word, excel and powerpoint, that's it. Maybe java, but it seems...
1
by: Bhavya Shah | last post by:
Hello All, I am facing a serious problem while copying a file to a remote computer programmatically. What I want to do: I want to connect to a remote computer and copy a file to the remote...
2
by: okaminer | last post by:
I writing VB.NET Code using Acrobat 6 API functions and my problem is with the following code: _formApp = New AFORMAUTLib.AFormAppClass _acroForm = _formApp.Fields The problem is that when I...
1
by: schaf | last post by:
Hi all! I'm still trying to start/stop a service on a remote computer. (I promiss that's the last new post because of this problem from my side) My situation: I've an application running under...
0
by: Paul Brady | last post by:
I volunteer at a youth ministry agency and help them with their student database. They have two computers, both running Windows XP. Both have Office 2002 installed without Access, except that...
2
by: subsanta | last post by:
My computer has so many problems and ive looked around on the internet and ive managed to fix some of them. I know that i have a few viruses on my computer, but i cant get rid of them, in one case i...
1
by: TC | last post by:
I'm experiencing an unusual problem. When I run a specific make-table query on a computer, that computer shuts down. The computer shuts down completely, without warning, as if a power failure...
3
by: Earl Anderson | last post by:
One of the users in our departmental db has Read/Write permissions to a particular form. He was able to access and edit the form at will until 2 weeks ago. His current problem was that he was not...
4
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
Hi, I am using Visual Studio 2003. After moving my project to a new development computer my project compiles and works on the new development computer but the program will not work when I...
9
by: Salad | last post by:
I have access, for testing at my client's site, a Win2000 computer running A2003 retail. He recently upgraded all of his other machines to DualCore Pentiums with 2 gig ram and run A2003 runtime. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.