Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
0 of .
Results for:
P. 1
print c++

# print c++

Ratings: 0|Views: 67|Likes:
c++ programs
c++ programs

### Availability:

See More
See less

11/07/2012

pdf

text

original

Program 1: W.A.P to show divide by zero exception.
#include<iostream.h>#include<conio.h>void divide(double a,double b);void main(){double i,j;cout<<"Enter numerator: ";cin>>i;cout<<"Enter denominator: ";cin>>j;divide(i,j);getch();}void divide(double a,double b){ Try{if(!b)throw b;cout<<"Result: "<<a/b<<endl;}catch(double b){cout<<"Can't divide by zero.\n"; }}
Output:
1

Enter numerator: 12Enter denominator:6Result: 2
Program 2: W.A.P to read and remove all duplicateelements in an array.
2

#include<iostream.h>#include<conio.h>int unique(int *,int);void main(){clrscr();int a[20];int n;cout<<"enter the no. of elements in array\n";cin>>n;cout<<"enter the elements in array\n";for(int i=0;i<n;i++)cin>>a[i];cout<<endl;n=unique(a,n);cout<<"array after removing the duplicates: \n";cout<<"{";for(i=0;i<n;i++)cout<<a[i]<<",";cout<<"}";getch();}int unique(int *a,int n){int i,k;k=0;cout<<"duplicated elements are: \n";for(i=1;i<n;i++)3

## Activity (1)

### Showing

AllMost RecentReviewsAll NotesLikes