Vcoderz Community
We create websites that have it all, beauty & brains
Lebanon Web Design & Development - Coddict
 

Go Back   Vcoderz Community > Computer Zone > Computers & Information Technologies > E-Learning Center

Notices

E-Learning Center « E-Learning tutorials and competitions. »

Reply
 
Share Thread Tools Search this Thread
Old 11-07-2008   #1
bitarno
Registered Member
 
bitarno's Avatar
 
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
Default C++ Help

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
bitarno is offline   Reply With Quote
Old 11-07-2008   #2
Sheriff Ice
info@sync.com.lb
 
Sheriff Ice's Avatar
 
Last Online: 06-05-2018
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
Default Re: C++ Help

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
Sheriff Ice is offline   Reply With Quote
Old 11-07-2008   #3
Google

 
Google's Avatar
 
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
Default Re: C++ Help

Quote:
Originally Posted by icemaker View Post
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
Why not posting them here, so we can all benefit

Quote:
more to come later
Waiting for this more
Bring us shi desem
Google is offline   Reply With Quote
The Following User Says Thank You to Google For This Useful Post:
Sogelec (11-07-2008)
Old 11-07-2008   #4
Kingroudy
Super Moderator
 
Kingroudy's Avatar
 
Last Online: 02-20-2014
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
Default Re: C++ Help

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.
Kingroudy is offline   Reply With Quote
Old 11-08-2008   #5
Sheriff Ice
info@sync.com.lb
 
Sheriff Ice's Avatar
 
Last Online: 06-05-2018
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
Default Re: C++ Help

Quote:
Originally Posted by Edgard Chammas View Post
Why not posting them here, so we can all benefit


Waiting for this more
Bring us shi desem
Ill post them 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
Sheriff Ice is offline   Reply With Quote
Old 11-08-2008   #6
bitarno
Registered Member
 
bitarno's Avatar
 
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
Default Re: C++ Help

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
bitarno is offline   Reply With Quote
Old 11-08-2008   #7
Google

 
Google's Avatar
 
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
Default Re: C++ Help

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;
}
Google is offline   Reply With Quote
Old 11-08-2008   #8
Tawa
 
Tawa's Avatar
 
Last Online: 08-02-2018
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,120
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
Default Re: C++ Help

Quote:
Originally Posted by bitarno View Post

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)
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.
Tawa is offline   Reply With Quote
Old 11-08-2008   #9
Sheriff Ice
info@sync.com.lb
 
Sheriff Ice's Avatar
 
Last Online: 06-05-2018
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
Default Re: C++ Help

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:&quot;Cambria Math&quot;; 	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:&quot;&quot;; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:&quot;Times New Roman&quot;,&quot;serif&quot;; 	mso-fareast-font-family:&quot;Times New Roman&quot;; 	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;} -->     
EX:2.16:
#include<iostream> //chapter 2 ex2.16 using namespace std; int main() { double galon,mil,total,m,ave; m=0; total=0; cout<<"enter the gallons used, -1 to end: \n"; cin>>galon; while(galon!=-1) { total=total+galon; cout<<"enter miles driven: \n"; cin>>mil; m=m+mil; cout<<"the miles/gallons for this tank was "<<mil/galon; //average for one entry cout<<endl<<"enter the gallons used, -1 to end: \n"; cin>>galon; } ave=(m/total); cout<<"the overall average is: "<<ave<<endl; //the overall average. return 0; } Ex:2.17: #include<iostream> #include<iomanip> using namespace std; int main() { int an; double bb,tc,cr,cl,b; cout<<"Enter the account number: (-1 to end)"<<endl; cin>>an; while(an!=-1) { cout<<"Enter the beginning balance: "<<endl; cin>>bb; cout<<endl<<"Enter total charges:"<<endl; cin>>tc; cout<<endl<<"Enter total credits: "<<endl; cin>>cr; cout<<endl<<"Enter credit limit: "<<endl; cin>>cl; cout<<endl; b=bb+tc-cr; if(b>=cl) { cout<<"Account"<<setw(8)<<an<<endl; cout<<"credit limit"<<setw(4)<<cl<<endl; cout<<"Balance"<<setw(8)<<b<<endl; cout<<"Credit limit exceeded"<<endl; } cout<<endl<<endl; cout<<"enter the account number: (-1 to end)"<<endl; cin>>an; } return 0; } Ex:2.18: #include<iostream>//exercise2.18 page 160 using namespace std; int main() { int ws; double sales,total,commission; ws=200; cout<<"enter sales in dollars (-1 to end):"<<endl; cin>>sales; while(sales!=-1) { commission=(9*sales)/100; total=ws+commission; cout<<"salary is: $"<<total<<endl<<endl; cout<<"enter sales in dollars (-1 to end):"<<endl; cin>>sales; } return 0; } Ex:2.19: #include<iostream> using namespace std; int main() { int hours,ratelow,extra; double ratehigh,bonus;; cout<<"enter hours worked (-1 to end)\n"; cin>>hours; while(hours!=-1) { cout<<"enter hourly rate of the worker($00.00): "<<endl; cin>>ratelow; ratehigh=ratelow*1.5; if(hours>40) { extra=hours-40; bonus=extra*ratehigh; cout<<"the salary is:$"<<bonus+40*ratelow<<endl; } else cout<<"the salary is:$"<<hours*ratelow<<endl<<endl; cout<<"enter hours worked (-1 to end)"<<endl; cin>>hours; } return 0; } Ex:2.20: #include<iostream> using namespace std; int main() { int counter=0,number=0,large=0; cout<<"enter number of sold objects\n"; cin>>number; while(counter<=10) { counter=counter+1; if(number>=large)large=number; cout<<"enter the number of sold objects\n"; cin>>number; } cout<<"the most sold is "<<large; return 0; } Ex:2.21: #include<iostream> using namespace std; int main() { int x; x=1; cout<<"N\t10*N\t100*N\t1000*N\n\n"; while(x<=5) { cout<<x<<"\t"<<x*10<<"\t"<<x*100<<"\t"<<x*1000<<endl;x++; } return 0; } problem 1: #include <iostream> using namespace std; void prime(int,int); int main() { int a,b; cout<<"enter the domain between 2 numbers u need to find the prime numbers:"<<endl; cin>>a>>b; prime(a,b); return 0; } void prime(int a,int b) { int i; int num=0; for (int j=a;j<=b;j++) { num=num+1; for (i=2; i<num; i++) { if((num%i)==0) { break; } } if (i >= num) { cout<<num<<endl; } } } problem 2 #include <iostream> #include <cmath> using namespace std; int main() { const int maxNumb = 10000; int sum, largestFactor, divisor; double started, ended; for (int lcv = 2; lcv < maxNumb; ++lcv) { sum = 1; largestFactor = (int)sqrt((double)lcv); for (divisor = 2; divisor <= largestFactor; ++divisor) { if (lcv % divisor == 0) { sum += divisor; if (divisor * divisor != lcv) sum += (lcv / divisor); } if (sum > lcv) break; } if (sum == lcv) cout << lcv << endl; } return 0; } problem 4 #include<iostream> #include<cstdlib> using namespace std; int main() { int x,y,z,a; while(a!=-1) { x=(1+rand() %9); y=(1+rand() %9); z=x*y; cout<<"how much is "<<x<<" times "<<y<<" ?"<<endl; cin>>a; while (a!=z) { cout<<endl<<"No, plz try again"<<endl; cin>>a; } cout<<"very good"<<endl; cout<<"enter -1 to exit or any number to continue"; cin>>a; } return 0; } problem 5 #include<iostream> #include<cstdlib> using namespace std; int main() { int x,y; char c; cout<<"want to play (y or n)"<<endl; cin>>c; while(c==y) { x=(1+rand()%1000); cout<<"i have a number between 1 and 1000."<<endl; cout<<"can you guess my number?"<<endl; cout<<"please type ur first guess"<<endl; cin>>y; while(y!=x) { if(y<=(x-10)) cout<<"Too low. Try again."<<endl; else if(y<x) cout<<"almost there."<<endl; else if(y>=(x+10)) cout<<"too high. Try again."<<endl; else if(y>10) cout<<"almost there."<<endl; cin>>y; } cout<<"excellent! you guessed the number!"<<endl; cout<<"would you like to play again (y or n)?"; cin>>c; } return 0; } problem 6 #include<iostream> #include<iomanip> #include<cstdlib> using namespace std; int main() { int tim1=0,tim2=0,tim3=0,tim4=0,tim5=0,tim6=0,face; for(int roll=1;roll<=6000;roll++) { face=1+rand()%6; switch (face) { case 1: ++tim1; break; case 2: ++tim2; break; case 3: ++tim3; break; case 4: ++tim4; break; case 5: ++tim5; break; case 6: ++tim6; break; default : cout<<"program should never get here!"; } } cout<<"Face"<<setw(15)<<"Times" <<"\n 1"<<setw(15)<<tim1 <<"\n 2"<<setw(15)<<tim2 <<"\n 3"<<setw(15)<<tim3 <<"\n 4"<<setw(15)<<tim4 <<"\n 5"<<setw(15)<<tim5 <<"\n 6"<<setw(15)<<tim6<<endl; return 0; } problem 11 #include<iostream> using namespace std; void draw_ESquare(int,char); int main () { int l;char c; cout<<"enter the character the lenght of your square: \n"; cin>>c>>l; cout<<endl; draw_ESquare(l,c); return 0; } void draw_ESquare(int l, char c) { for(int i=1;i<=l;i++) { for(int j=1;j<=l;j++) if(i==1||j==l) cout<<c; else cout<<" "; cout<<endl; } }
sorry i dont have the questions but if u read each example u will know what it do

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
Sheriff Ice is offline   Reply With Quote
Old 11-26-2008   #10
bitarno
Registered Member
 
bitarno's Avatar
 
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
Default Re: C++ Help

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
  • Average (sum/number of elements)
2.Median
  • Number in middle of sorted list
  • 1, 2, 3, 4, 5 (3 is median)
  • If even number of elements, take average of middle two
3.Mode
  • Number that occurs most often
  • 1, 1, 1, 2, 3, 3, 4, 5 (1 is mode)

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”
  • Redo the same thing for an array of characters.
EXERCISE 2
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”
  • Redo the same thing for an array of characters.

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
  • Redo the same thing for an array of characters.

EXERCISE 4
Develop a function that reads a string and prints it backwards on the screen.
Example: read “hello there” and produce “ereht olleh”
  • Redo the same thing for an array of characters.

EXERCISE 5
Write a myStrlen function which is the same as the library strlen function.
  • Redo the same thing for an array of characters.

EXERCISE 6
Write the myStrcpy function which is the same as the library strcpy function.
  • Redo the same thing for an array of characters.

EXERCISE 7
Write the myStrNcpy function which is the same as the library strncpy function.
  • Redo the same thing for an array of characters.

EXERCISE 8
Write the myStrcmp function which is the same as the library strcmp function.
  • Redo the same thing for an array of characters.

EXERCISE 9
Write the myStrNcmp function which is the same as the library strncmp function.
  • Redo the same thing for an array of characters.
EXERCISE 10
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.
  • Redo the same thing for an array of characters.

Thx Alot Guys ... Remember Visual C++ compiler

__________________
“Please dnt call me arrogant,but Im European champion & I think Im a special one." Jose Mourinho
bitarno is offline   Reply With Quote
Reply

  Vcoderz Community > Computer Zone > Computers & Information Technologies > E-Learning Center



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:51 AM.


Lebanon web design and development
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Share