Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,246 members, 7,953,926 topics. Date: Friday, 20 September 2024 at 09:05 AM |
Nairaland Forum / Science/Technology / Programming / Help Me With C++ Assisgnment (1293 Views)
Why You Should Start Programming With C. / Finger Print Application With C# / Help On How A Make An App A Trial Version With C# (2) (3) (4)
Help Me With C++ Assisgnment by Juniorroged(m): 7:18am On Mar 12, 2013 |
Hi NL please ȋ̝̊ need solutions to these questions; 1. Using the if-else statement, write a prog to find whether the number is even or odd. 2. Write a prog to find the square of the first natural numbers using the loop. 3.Write a program to print the first 100 prime numbers. Using cin & cout. 4. Write a program to produce the first 100 fibonacci numbers. 5. The factorial of an integer n, written n!, is the product of the consecutive integers 1 through n. For example 5 factorial is calculated as 5!= 5*4*3*2*1=120 write a program to generate and print a table of the first 10 factorials.4. Produce a table showing values of x the square of x and the cube of x for values of x from 1 to 50. ȋ̝̊ need help on this. Please |
Re: Help Me With C++ Assisgnment by FXKing2012(m): 7:28am On Mar 12, 2013 |
And what do I get for teaching you?. |
Re: Help Me With C++ Assisgnment by Nairaplus(m): 7:33am On Mar 12, 2013 |
Let me try! |
Re: Help Me With C++ Assisgnment by Burger01(m): 8:10am On Mar 12, 2013 |
For number 1 try and run the following codes: Option 1: 'C++' *** Please, its been a while i did programming.. forgive me if it didn't run.. and I suggest you try playing around with some very simple function calls until things become clear as you won't be able to do very much at all in C++ without understanding the concept. See what Seun's unintelligent software dey do to my codes!.. Try and quote my post and you would see the actual codes for Option 2.. |
Re: Help Me With C++ Assisgnment by ciphoenix: 8:32am On Mar 12, 2013 |
This is spoon feeding, nothing more. That number 1, for real? Have you read any book on c++ programming? |
Re: Help Me With C++ Assisgnment by Burger01(m): 8:33am On Mar 12, 2013 |
For Number 2 try the following codes: #include <iostream> using namespace std; int main(){ double buffer; cout<<"Please enter a positive number, negative to exit:\n"; cin>>buffer; while(buffer >= 0){ cout<<"The square of "<<buffer<<" is: "<<buffer*buffer<<endl; cout<<"Please enter a positive number, negative to exit:\n"; cin>>buffer; }//end while return 0; } For number 3 try these codes: #include <iostream> using namespace std; //using namespace system; int isPrime(long num) // Returns 1 (true) if its prime, or 0 (false) if not { if (num < 2) // 1 is not a prime number return 0; // if it is > 2 and an even number, then it definitely is not a prime if (num > 2 && (num % 2) == 0) return 0; //considering the fact all can be divided by 1 and itself, //start checking if there is any other divisor, if found one then no need to continue, it is not a prime for(int i = 2; i < num; i++ ) { cout << " divisor: " << i << endl; if ( (num % i) == 0) // if it is divisible by i { // a divisor other than 1 and the number itself return 0; // no need for further checking } } return 1; // if all hurdles/checks are crossed, hey, its a prime } int main() { int num; do { cout << " enter a number (0 to stop) " << endl; cin >> num; if (num) { if (isPrime(num)) cout << num << " is a prime numebr " << endl; else cout << num << " is NOT a prime numebr " << endl; } } while (num > 0); return 0; } You can put a counter is solution 3 to meet your needs.. try the rest on your own. Programming is easy if you know the syntax and some function. Try and read books and lecture notes on C++ and you will be fine.. Have a nice day. My head is already becoming heavy with these codes... |
(1) (Reply)
Do You Need An Ecommerce Android App (check Out Sample Screenshots Inside) / Become An Expert In Java Programming!!! / VACANCY: Software Developer (java Enterprise-mobile Developer) WORK FROM HOME
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17 |