include<iostream.h>#include<conio.h>#include<math.h>void main(){float a,b,c,disc,root1,root2;cout<<"enter a"<<endl;cin>>a;cout<<"enter b"<<endl;cin>>b;cout<<"enter c"<<endl;cin>>c;disc=(b*b)-(4*a*c);root1=(-b+sqrt(disc))/(2*a);root2=(-b-sqrt(disc))/(2*a);cout<<"root1"<<root1<<endl;cout<<"root2"<<...
Thursday, 31 January 2013
structure in c++ by zafar iqbal
#include<iostream.h>#include<conio.h>struct student{int rollno;int marks;float avg;char grade;};void main(){student s;cout<<"enter roll no"<<endl;cin>>s.rollno;cout<<"enter marks"<<endl;cin>>s.marks;cout<<"enter average"<<endl;cin>>s.avg;cout<<"enter grade"<<endl;cin>>s.grade;cout<<s.rollno<<endl;cout...
transpose of a matrix in c++
#include<iostream.h>#include<conio.h>void main(){int r,c,i,j;int matrix[12][12];int transpose[12][12];cout<<"enter no of rows of matrix ";cin>>r;cout<<"enter no of columns of matrix ";cin>>c;cout<<"\n\n";for(i=0;i<r;i++)for(j=0;j<c;j++){cout<<"matrix["<<i<<"]["<<j<<"]"<<" ...
Actual and reverse in array in c++
#include<iostream.h>#include<conio.h>void main(){int ham[5],i;for(i=1;i<=5;i++){cout<<"enter an integer"<<endl;cin>>ham[i];}cout<<"actual value"<<endl;for(i=1;i<=5;i++)cout<<ham[i]<<endl;cout<<"reverse value"<<endl;for(i=5;i>0;i--)cout<<ham[i]<<endl;getch()...
Wednesday, 30 January 2013
vowel or not in c++
#include<iostream.h>#include<conio.h>void main(){clrscr();char n;cout<<"enter the alphabet"<<endl;cin>>n;switch(n){case 'a':case 'A':cout<<"vowel";break;case 'e':case 'E':cout<<"vowel";break;case 'i':case 'I':cout<<"vowel";break;case 'o':case 'O':cout<<"vowel";break;case 'u':case 'U':cout<<"vowel";break;default:cout<<"not vowel";b...
Average greater than give %age show cong...in c++
include<iostream.h>#include<conio.h>void main(){int e,u,m,avg;cout<<"enter marks of eng"<<endl;cin>>e;cout<<"enter marks of urd"<<endl;cin>>u;cout<<"enter marks of math"<<endl;cin>>m;avg=(e+u+m)/3;if(avg>80){cout<<"you are above standard"<<endl;cout<<"admission granted"<<endl;}getch()...
Area and circumference in c++
include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
const float pi=3.14159;
float radius,area,circum;
//read radius of a circle
cout<<"enter r"<<endl;
cin>>radius;
//compute area
area=pi*radius*radius;
cout<<"the area"<<area<<endl;
//comput circumference
circum=2*pi*radius;
cout<<"circum"<<circum<<endl;
getc...
Tuesday, 29 January 2013
single,complete,average link clustring using Matlab
x=input('x=');
y=input('Y=');
subplot(4,1,1);
plot(x,y,'r*');
xlabel('x-Values')
ylabel('Y-Values')
n=length(x);
j=1;
i=1;
k=1;
while j<n
for i=i:n-1
e_dis=sqrt(((x(i+1)-x(j)).^2)+((y(i+1)-y(j)).^2));
d(k)=e_dis; %#ok<AGROW>
k= k+1;
end
j=j+1;
i=j;
...
Average_Link Clustring Using Matlab
x=input('x=');
y=input('Y=');
subplot(2,1,1);
plot(x,y,'r*');
xlabel('x-Values')
ylabel('Y-Values')
n=length(x);
j=1;
i=1;
k=1;
while j<n
for i=i:n-1
e_dis=sqrt(((x(i+1)-x(j)).^2)+((y(i+1)-y(j)).^2));
d(k)=e_dis; %#ok<AGROW>
k= k+1;
display(e_dis);
end
j=j+1;
...
complete_link clustring Using Matlab
x=input('x=');
y=input('Y=');
subplot(4,1,1);
plot(x,y,'r*');
xlabel('x-Values')
ylabel('Y-Values')
n=length(x);
j=1;
i=1;
k=1;
while j<n
for i=i:n-1
e_dis=sqrt(((x(i+1)-x(j)).^2)+((y(i+1)-y(j)).^2));
d(k)=e_dis; %#ok<AGROW>
k= k+1;
end
j=j+1;
i=j;
...
Single Link clustering using matlab
%Single Link_Clustring
x=input('x=');
y=input('Y=');
subplot(2,1,1);
plot(x,y,'r*');
xlabel('x-Values')
ylabel('Y-Values')
n=length(x);
j=1;
i=1;
k=1;
while j<n
for i=i:n-1
e_dis=sqrt(((x(i+1)-x(j)).^2)+((y(i+1)-y(j)).^2));
d(k)=e_dis; %#ok<AGROW>
k= k+1;
display(e_dis);
end
...
Friday, 25 January 2013
Thursday, 24 January 2013
Wednesday, 23 January 2013
Insertion in Array
#include <iostream>
#include <conio>
void main()
{
int arr[6];
int a;
cout<<"Enter integer in arrays"<<endl;
for(int i=0;i<5;i++)
{
cin>>arr[i];
}
for(int i=0;i<5;i++)
{cout<<"["<<arr[i]<<"]"<<" ";
}cout<<endl;
int s=6;
for(int i=0;i<=2;i++)
{
arr[s]=arr[s-1];
s--;}
cin>>arr[3];
for(int i=0;i<6;i++)
{cout<<"["<<arr[i]<<"]"<<"...
Binary to Decimal conversion using c++
#include <iostream.h>
#include <conio.h>
void main()
{
int n,b,d,arr[10],ar[10],a[10];
cout<<"enter how many no"<<endl;
cin>>n;
b=0;
n--;
for(int i=n;i>=0;i--)
{
cout<<"enter binary no"<<endl;
cin>>arr[i];
b++;
}
n=1;
for(int i=0;i<=b;i++)
{
ar[i]=n;
n=n*2;}
b--;
for(int j=0;j<=b;j++)
{
a[j]=arr[j]*ar[j];
d=0;
for(int j=0;j<=b;j++)
d=...
Returning values from fuction and also passing value to the function in matlab
%--------------Returning values from fuction and also passing value to the functions-------%
a=input('Enter 1st num\n');
b=input('Enter 2nd num\n');
c=input('Enter 3rd num\n');
p=ret(a,b,c);
fprintf('the product of your 3 number is=%d\n',p);
%--------------===============================--------------------------------------------%
function[z]=ret(a,b,c);
z=a*b*c;
basically in c,c++...
Value return from function
%---------------------------
main file c is
p=show();
fprintf('cube=%d\n',p);
%--------------------------
%here i use a program that tell us how value return from function %
function[z]=show();
x=input('Enter any number\n');
z=1;
z=x*x*x;
in c++ we use this syntax as
%------------------------------
z=x*x*x;
return z;
but here we return the variable in the above...
Tuesday, 22 January 2013
constructer
#include<iostream.h>
#include<conio.h>
class student
{
private:
int marks;
char grade;
public:
student () //constructer
{
marks=80;
grade='A';
}
void show()
{
cout<<"\n marks is :"<<marks<<endl;
cout<<"\n the grade is :"<<grade<<endl;
}
};
void main()
{
student s1;
cout<<"record of s1";
s1.show();
getch();
...