Program to convert cartesian co-ordinates into polar co-ordinates C and C++

Program to convert cartesian co-ordinates into polar co-ordinates

#include<iostream.h> #include<math.h> class rect { private: float x, y, r, t; public: rect(); void polar(); void disp(); }; rect::rect() { cout<<“\n Enter x cordinate: “; cin>>x; cout<<“\n Enter the y cordinate: “; cin>>y; } void rect::polar() { r = sqrt(x*x+y*y); if(y<0) { if(x<0) { t = 180+tan(y/x)*180/3.14159265; } else t = tan(y/x)*180/3/14159265; } if(x>0 && […]

Program to add and multiply two matrix using OOP C and C++

Program to add and multiply two matrix using OOP

#include class matrix { private: int m, z[10][10]; public: int i, j, k; void getdata(); { cout<<“Enter the order of the square matrix: “; cin>m; cout<<“Enter the “<<m<<“*”<<m<<” elements: “<<endl; for(i=0;i<m;i++) for(j=0;j<m;j++) cin>>z[i][j]; } friend int check(matrix a, matrix b) { if(a.m == b.m) return 1; else return 0; } void display() { cout<<“Size is […]

Program to generate fibonacci series using constructor C and C++

Program to generate fibonacci series using constructor

#include<iostream.h> class fib { int n; public: fib(int a) { n = a; } fib() { n = 0; } void display() { if(n == 0) { cout<“\n No fibonacci number\n”; retun; } else if(n == 1) { cout<<“Fibonacci numbers are\n”<<“0″<<endl; return; } else if(n>2) { cout<<“Fibonacci numbers are\n”<<“0\t1”; } if f1=0,f2=1,f3,cnt; for(cnt = 1;cnt […]

C and C++

Write a program to insert an element into an array at a given position

#include<iostream.h> #include<iomanip.h> class insertion { private: int n, m[100], ele, p; public: void getdata(); void insert(); void display(); }; void insertion::getdata() { cout<<“How many elements?”; cin>>n; cout<<“Enter the elements: “; for(int i=0; i<n; i++) cin>>m[i]; cout<<“Enter the element to be inserted:”; cin>>ele; cout<<“Enter the position (0 to “<<n<<“):”; cin>>p; } void insertion::insert() { if(p>n) { cout<<p<<“is an invalid position”; exit(0); } else { for(int i=n-1; i>=p; i–) m[i+1] = m[i]; m[p] = ele; n = n+1; cout<<ele<<” is successfully inserted”<<endl; } } void insertion::display() { cout<<“The array after the insertion is “; for(int i=0; i<n; i++) cout<<setw(4)<<m[i]; } void […]

Computer Graphics

Raster-Scan Display Processor

Figure shows one way to organize the components of a raster system that contains a separate display processor, sometimes referred to as a graphics controller or a display coprocessor. Scan conversion: A major task of the display processor is digitizing a picture definition given in an application program into a set of pixel values for […]