|
|
|||||||
| E-Learning Center « E-Learning tutorials and competitions. » |
![]() |
|
|
Share | Thread Tools | Search this Thread |
|
|
#1 |
|
Registered Member
Last Online: 10-13-2012
Join Date: May 2006
Posts: 582
Thanks: 237
Thanked 437 Times in 221 Posts
Groans: 10
Groaned at 9 Times in 8 Posts
|
hey guys i'd like to receive some help by some programs in C++ thanks
I use Visual C++ so i hope the code would be convenient 1st Excersice
Write a complete C++ code in which you develop a function to compute n factorial N factorial = n! = 1*2*3*…*n In this code, you read the value of n from the user and you pass it to the function. 2nd Exercise Consider the following series x(n) = 1/n + 1/(n-1) + … + 1 for all n > 0 x(1) = 1 Develop a recursive function to compute the value of x(n) 3rd Exercise Write a C++ code that generates a random number between -10 and +15 ( this one we should use rand()%... something like that ) Thx Guys in advance more to come later
__________________
“Please dnt call me arrogant,but Im European champion & I think Im a special one." Jose Mourinho
|
|
|
|
|
|
#2 |
|
info@sync.com.lb
Last Online: 11-29-2020
Join Date: Apr 2006
Posts: 3,827
Thanks: 1,348
Thanked 2,391 Times in 1,306 Posts
Groans: 0
Groaned at 16 Times in 15 Posts
|
PM me i have them
i solved them the first year of uni i still have the solution on a word file and i can give you an e-book that it may help you
__________________
http://www.gamync.com Lebanese Produced Mobiles Games by http://www.sync.com.lb |
|
|
|
|
|
#4 |
|
Super Moderator
Last Online: 02-16-2022
Join Date: May 2006
Posts: 5,580
Thanks: 1,888
Thanked 2,653 Times in 1,593 Posts
Groans: 55
Groaned at 35 Times in 32 Posts
|
1st exercise:
int n, nf=1; cin>>n; for(int i=1; i<=n, i++) { nf*=i; } cout<<nf hayda L base taba3 L code.. it has been a full year i haven't touched c++, and i have an exam tomorrow so i can't stay long for this.
__________________
click on 'Groan' to switch to my left testicle. |
|
|
|
|
|
#5 | |
|
info@sync.com.lb
Last Online: 11-29-2020
Join Date: Apr 2006
Posts: 3,827
Thanks: 1,348
Thanked 2,391 Times in 1,306 Posts
Groans: 0
Groaned at 16 Times in 15 Posts
|
Quote:
ma te3tal ham just give me till afternoon i am at work ill post them as i get home
__________________
http://www.gamync.com Lebanese Produced Mobiles Games by http://www.sync.com.lb |
|
|
|
|
|
|
#6 |
|
Registered Member
Last Online: 10-13-2012
Join Date: May 2006
Posts: 582
Thanks: 237
Thanked 437 Times in 221 Posts
Groans: 10
Groaned at 9 Times in 8 Posts
|
I want also a code for a program to change a number entered by a user into binary
__________________
“Please dnt call me arrogant,but Im European champion & I think Im a special one." Jose Mourinho
|
|
|
|
|
|
#7 |
|
Last Online: 05-30-2013
Join Date: Jan 2008
Posts: 1,788
Thanks: 10,018
Thanked 1,100 Times in 651 Posts
Groans: 1
Groaned at 6 Times in 6 Posts
|
Decimal to Binary Converter:
Code:
#include <iostream.h>
void binary(int);
void main() {
int number;
cout << "Enter a positive integer: ";
cin >> number;
if (number < 0)
cout << "The number must be positive you idiot!\n";
else {
cout << number << " is ";
binary(number);
cout<<" in binary.\n\n";
}
}
void binary(int n) {
int rem;
if(n <= 1) {
cout << n;
return;
}
rem = n%2;
binary(n >> 1);
cout << rem;
}
|
|
|
|
|
|
#8 | |
|
Last Online: 12-20-2021
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,121
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
|
Quote:
Code:
#include <iotream>
using namespace std;
double function(int);
int main(void)
{
int n;
double x;
do{
cout << "Enter n: ";
cin >> n;
}while(n<1);
x = function(n);
cout << "X(n) = " << x << endl;
return 0;
}
double function(int n)
{
if(n == 1)
return 1;
return 1/n + function(n-1);
}
Damn I Miss The C++
__________________
What we do in life, echoes in eternity.
|
|
|
|
|
|
|
#9 |
|
info@sync.com.lb
Last Online: 11-29-2020
Join Date: Apr 2006
Posts: 3,827
Thanks: 1,348
Thanked 2,391 Times in 1,306 Posts
Groans: 0
Groaned at 16 Times in 15 Posts
|
Code:
1.23
#include<iostream>
using namespace std;
int main()
{
int x,y;
cout<<"enter your first integer:\n";
cin>>x;
cout<<endl<<"enter your second integer:\n";
cin>>y;
cout<<endl<<"the sum is: "<<x+y<<endl<<"the product is: "<<x*y<<endl<<"the difference is: "<<x-y<<endl<<"the quotion is: "<<x/y<<endl;
return 0;
}
1.24
#include<iostream>
using namespace std;
int main()
{
int x;
x=0;
if(x<=4)
cout<<x;
return 0;
}
1.25
#include<iostream>
using namespace std;
int main()
{
int x,y;
cout<<"enter your first integer; \n";
cin>>x;
cout<<endl<<"enter your second integer; \n";
cin>>y;
cout<<endl;
if(x>y)
cout<<x<<" is larger"<<endl;
else if(y>x)
cout<<y<<" is larger"<<endl;
else if(x==y)
cout<<"these number are equal "<<x<<" = "<<y<<endl;
return 0;
}
1.26
#include<iostream>
using namespace std;
int main()
{
int x,y,z,sum,ave,pro;
cout<<"Input three different integers: ";
cin>>x>>y>>z;
sum=x+y+z;
cout<<"sum is "<<sum<<endl;
ave=(x+y+z)/3;
cout<<"average is "<<ave<<endl;
pro=x*y*z;
cout<<"product is "<<pro<<endl;
return 0;
}
1.30
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e;
cout<<"enter the 5 values:\n";
cin>>a>>b>>c>>d>>e;
if(a<b,a<c,a<d,a<e)
cout<<"the smallest "<<a<<endl;
else if(b<a,b<c,b<d,b<e)
cout<<"the samallest "<<b<<endl;
else if(c<a,c<b,c<d,c<e)
cout<<"the smallest "<<c<<endl;
else if(d<a,d<b,d<c,d<e)
cout<<"the smallest "<<d<<endl;
else
cout<<"the smallest "<<e<<endl;
}
{
if(a>b,a>c,a>d,a>e)
cout<<"the largest "<<a<<endl;
else if(b>a,b>c,b>d,b>e)
cout<<"the largest "<<b<<endl;
else if(d>a,d>b,d>c,d>e)
cout<<"the largest "<<d<<endl;
else if(c>a,c>b,c>d,c>e)
cout<<"the largest "<<c<<endl;
else
cout<<"the largest "<<e<<endl;
return 0;
}
1.31
#include<iostream>
using namespace std;
int main()
{
int x,y;
cout<<"enter your integer: \n";
cin>>x;
if(x%2)
cout<<x<<" is even\n";
else
cout<<x<<" is odd\n";
cout<<"enter your integer \n";
cin>>y;
if(y%2)
cout<<y<<" is even\n";
else
cout<<x<<" is odd\n";
return 0;
}
1.32:
x 1.32:
#include <iostream>
using namespace std;
int main()
{
int x,y;
cout<<"Enter two integers\n";
cin>>x>>y;
if (x%y==0)
cout<<x<<"is multiple of"<<y;
return 0;
}
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-bidi-language:AR-LB;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->
these are the exercises that i found i still have two e-books c++ ill post them later by tonight
__________________
http://www.gamync.com Lebanese Produced Mobiles Games by http://www.sync.com.lb |
|
|
|
|
|
#10 |
|
Registered Member
Last Online: 10-13-2012
Join Date: May 2006
Posts: 582
Thanks: 237
Thanked 437 Times in 221 Posts
Groans: 10
Groaned at 9 Times in 8 Posts
|
Guys New Updates :
Arrays
Develop a C++ code where you declare an array of 50 elements. After assigning random values to your array, you need to compute the Mean, Median and Mode. 1.Mean
2D Arrays Exercise 1 Develop a C++ code where you declare a 2 dimensional array A of 50 rows and 30 columns. 1.Develop a function that assigns random values to your array. Each random value r should satisfy the following relation: -120 < r < 100 or r > 300. 2.Develop a function that generates a new array B in which you store the average of the elements stored over the same column in array A Exercise 2 There are three students and there have been 4 quizzes. The results are ·first student got 77, 68, 86, 73 ·second student got 96, 87, 89, 78 ·third student got 70, 90, 86, 81 Goal 1.Develop a function that prints the grades of students 2.Develop a function that finds the highest grade 3.Develop a function that finds the lowest grade 4.Develop a function that computes the average of each student Hint: Use a multiple-subscripted array (table) ·Rows are students Columns are grades Strings EXERCISE 1 Develop a function that reads a string, removes all space from that string and prints out the result on the screen. Example: read “hello there” and produce “hellothere”
Develop a function that reads a string, replaces all letters “e” by “a” and prints out the result on the screen Example: read “hello there” and produce “hallo thara”
EXERCISE 3 Develop a function that reads a string, finds the most repeated letter, and prints out the result on the screen. Example: read “hello there” and produce “e” is the most repeated lettre
EXERCISE 4 Develop a function that reads a string and prints it backwards on the screen. Example: read “hello there” and produce “ereht olleh”
EXERCISE 5 Write a myStrlen function which is the same as the library strlen function.
EXERCISE 6 Write the myStrcpy function which is the same as the library strcpy function.
EXERCISE 7 Write the myStrNcpy function which is the same as the library strncpy function.
EXERCISE 8 Write the myStrcmp function which is the same as the library strcmp function.
EXERCISE 9 Write the myStrNcmp function which is the same as the library strncmp function.
Write a program that reads a line from the keyboard, and stores that line in a string. a.Develop a function that allows you to insert a word wherever you want in that string. b.Develop a function that allows you to delete any word of that string.
Thx Alot Guys ... Remember Visual C++ compiler
__________________
“Please dnt call me arrogant,but Im European champion & I think Im a special one." Jose Mourinho
|
|
|
|
![]() |
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|