473,397 Members | 1,949 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,397 software developers and data experts.

Need a program that can answer the following problems

1. The program should be able to solve the following problems
a. decision to be made if a given number is a prime
b. Fibonacci number calculation (F1=1, F2=1, Fn=Fn-2+Fn-1)
c. determinant computation (of order 1 and order 2, extra credit: order 3)
d. matrix addition (should work 2x2, 2x3 and 3x3 matrices, e. matrix multiplication (at least 1xm and mx1 matrices

It should be done in C++ formatting
Nov 1 '06 #1
5 1624
Ganon11
3,652 Expert 2GB
So what have you been able to figure out so far?
Nov 1 '06 #2
So what have you been able to figure out so far?
Nothing really becuase this is only my 3rd time doing programming. The first two were just using couts and cins like ansering questions for a program. Im not sure how to use numbers. I tried this program for part a which is decison to be made if a given number is prime.

#include <iostream>

using namespace std;

int isprime(int Prime_Number);
int main()
{
int Number = 0;
cout<<"Enter a number"<<endl;
cin>>Number;
if(Number>0)
{
if(isprime(Number)==0)
{
cout<<"Number is prime"<<endl;
}
else
{
cout<<"Number is not prime"<<endl;
}
}
else
{
cout<<"Positive numbers only"<<endl;
}
return 0;
}


int isprime(int Prime_Number)
{
//prime number calculation here
}
Nov 1 '06 #3
willakawill
1,646 1GB
Nothing really becuase this is only my 3rd time doing programming. The first two were just using couts and cins like ansering questions for a program. Im not sure how to use numbers. I tried this program for part a which is decison to be made if a given number is prime.

#include <iostream>

using namespace std;

int isprime(int Prime_Number);
int main()
{
int Number = 0;
cout<<"Enter a number"<<endl;
cin>>Number;
if(Number>0)
{
if(isprime(Number)==0)
{
cout<<"Number is prime"<<endl;
}
else
{
cout<<"Number is not prime"<<endl;
}
}
else
{
cout<<"Positive numbers only"<<endl;
}
return 0;
}


int isprime(int Prime_Number)
{
//prime number calculation here
}
As a clue: you should be checking out the Mod operator
Nov 1 '06 #4
Banfa
9,065 Expert Mod 8TB
You need to know what algorithm to use to find before you worry about putting it into code.

For instance I assume you know what a prime number is? So on paper how would you answer the question "Is 221 a prime number?"?

Can you make the computer do the same thing for any number?
Nov 1 '06 #5
You need to know what algorithm to use to find before you worry about putting it into code.

For instance I assume you know what a prime number is? So on paper how would you answer the question "Is 221 a prime number?"?

Can you make the computer do the same thing for any number?

I run the program and it says this

Warning W8070 roach5.cpp 33: Function should return a value in function isprime(
int)
Warning W8057 roach5.cpp 33: Parameter 'Prime_Number' is never used in function
isprime(int)
Nov 12 '06 #6

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

Similar topics

4
by: kazack | last post by:
I posted a similiar question in this newsgroup already and got an answer which I already knew but didn't get the answer I was looking for so I am reposting the code and question differently in the...
29
by: steve | last post by:
Hi, Recently I have been looking at the various ways people are implementing, interaction between java & oracle databases. I was always instructed on the purity of the data model, "normalize...
29
by: RAY | last post by:
Hi , my boss has asked I sit in on an interview this afternoon and that I create some interview questions on the person's experience. What is C++ used for and why would a company benefit from...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: beg_c++ | last post by:
hi i am a beginner in c++, i have a project to be done by few weeks. This project is a maths help for kids!! it is supposed to ask the kid how many problems the kid want and then show the problems...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
7
by: Malcolm | last post by:
This is a program to convert a text file to a C string. It is offered as a service to the comp.lang.c community. Originally I thought it would be a five minute job to program. In fact there are...
20
by: Robbie Hatley | last post by:
I needed a quick program called "random" that gives a random positive integer from n1 to n2. For example, if I type "random 38, 43", I want the program to print a random member of the set {38,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.