Your SlideShare is downloading. ×
1   borland c++ 5.02 by aramse
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

1 borland c++ 5.02 by aramse

322
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
322
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCSInstall Borland C++ 5.02 to your computerFirst how to open the DOS(standard) to write a C++ programFile New Project… ok Target Name: Your name Platform DOS(Standard)okDouble click on Your name or (proj0023.cpp[.cpp])
  • 2. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCS#include <iostream.h>#include <conio.h>int x,y;main(){cout<<"X=";cin>>x;cout<<"Y=";cin>>y;if(x>y)cout<<"X is Largest="<<x;elsecout<<"Y is Largest="<<y;getch();}X=4Y=7Y is Largest=7#include <iostream.h>#include <conio.h>int a,b,c;main(){cout<<"Please insert two numbers:n";cin>>a>>b;cout<<"a="<<a<<" b="<<b;c=b;b=a;a=c;cout<<"nYour Swap is:n";cout<<"a="<<a<<" b="<<b;getch();}Please insert two numbers:3 4a=3 b=4Your Swap is:a=4 b=3Q1/Write a C++ programming to read two values then print out the largest?Q2/Write a C++ program to swap the values of two variables say a,b?
  • 3. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCS#include <iostream.h>#include <conio.h>#include <math.h>int x,y,e;main(){cout<<"X=";cin>>x;if(x>0){cout<<"E=";cin>>e;y=pow(e,x)+5;cout<<"Y="<<y;}else{y=x+7;cout<<"Y="<<y;}getch();}X=3E=4Y=69X= -4Y=3Q3/Write C++ program to evaluate y depending on x value as in the following condition:If x>0 then y=ex+5;If x<0 then y=x+7Or
  • 4. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCSN=3X=4X=5X=6Sum=15#include <iostream.h>#include <conio.h>int l,w,area;main(){cout<<”L=”;cin>>l;cout<<”W=”;cin>>w;area=l*w;cout<<"Area="<<area;getch();}L=4W=5Area=20Q4/Write a C++ program to compute the sum of a set of N values.Q5/Write C++ program to calculate the area of rectangle from this formula a=l*w#include <iostream.h>#include <conio.h>int i,n;float x,sum;main(){cout<<"N=";cin>>n;i=0;sum=0.;while (i<n){i=i+1;cout<<"X=";cin>>x;sum=sum+x;}cout<<"Sum="<<sum;getch();}
  • 5. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCS#include <iostream.h>#include <conio.h>int i,n;float l,w,a;main(){cout<<"N=";cin>>n;for(i=1;i<=n;i++){cout<<"nL=";cin>>l;cout<<"W=";cin>>w;a=l*w;cout<<"Area="<<a;}getch();}N=3L=4.5W=5Area=22.5L=5W=6Area=30L=6W=7Area=20Q6/ C++ program to calculate the area of rectangle from this formula a=l*w repeated for nvalues of l and w.
  • 6. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCS#include <iostream.h>#include <conio.h>int i,n,sum;main(){cout<<"N=";cin>>n;sum=0;for(i=1;i<=n;i++){sum=sum+i;}cout<<"Sum="<<sum;getch();}N=12Sum=78#include <iostream.h>#include <conio.h>int i,n,sum;main(){cout<<"N=";cin>>n;i=0;sum=1;while(i<n){i=i+1;sum=sum*i;}cout<<"Sum="<<sum;getch();} N=5Sum=120Q7/Write C++ program to find the value of sum from this formula sum=1+2+3+4+…nQ8/ Write C++ program to find the value of sum from N! , N! = 1*2*3*4*…nTry to use (if…else, for, while) for this question Q8/A and B
  • 7. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCSQ11/Write C++ program to read numbers till a negative numbers is entered and calculatesum of a list of numbers read.
  • 8. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCS#include <iostream.h>#include <conio.h>#include <math.h>int i,x,sum;main(){for(i=1 ; i<=4 ; i++){cout<<”nX=”;cin>>x;sum=pow(x,2);cout<<"Sum="<<sum;}getch();}X=3Sum=9X=4Sum=16X=5Sum=25X=Sum=36Q12/Write C++ program to find the square numbers of a list of 4 numbers.
  • 9. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCSM=3Y=4Y=5Y=7K=16 E=5.33333#include <iostream.h>#include <conio.h>int j,m;float k,y,e;main(){k=0.;cout<<"m=";cin>>m;for(j=1 ; j<=m ; j++){cout<<endl<<"Y=";cin>>y;k=k+y;}e=k/m;cout<<"K="<<k<<"tE="<<e;getch();}#include <iostream.h>#include <conio.h>int j,m;float k,y,e;main(){k=0.;cout<<"m=";cin>>m;for(j=1 ; j<=m ; j++){cout<<endl<<"Y=";cin>>y;k=k+y;}e=k/m;cout<<"K="<<k<<"tE="<<e;getch();}Q13/write a C++ program to produce this result:M is a setY is the numbers of the setK=K+YE=K/MIf we replace “for statement” to “while statement” we write:
  • 10. PROGRAMMING C++January 1,2012Dr.Selar by:ARAMCSN=22 5Z=2 Y=4Z=5 Y=25#include <iostream.h>#include <conio.h>#include <math.h>int i,n;float z,y;main(){cout<<"N=";cin>>n;for(i=1 ; i<=n ; i++){cin>>z;y=pow(z,2);cout<<"Z="<<z<<"tY="<<y<<endl;}getch();}Q14/write a c++ program to Display on the screen this table