HOME

Sunday, November 29, 2015

PROGRAM FOR PUT AND GET FUNCTION IN FILE HANDLING

#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main()
{
    char str[50];
    cout<<"Enter the string"<<endl;
    cin>>str;
    fstream obj;
    obj.open("abc.txt",ios::in|ios::out);
    int length;
    length=strlen(str);
    for(int i=0;i<length;i++)
    {
        obj.put(str[i]);
    }
    obj.seekg(0,ios::beg);
    cout<<"READING FROM FILE"<<endl;
    char ch;
    while(obj)
    {
        obj.get(ch);
        cout<<ch;
    }
    obj.close();
    return 0;
}

WRITING AND READING FROM FILE USING CONSTRUCTOR FUNCTION

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
    char name[20];
    int age;
    cout<<"ENTER NAME AND AGE"<<endl;
    cin>>name>>age;
    ofstream obj("1.txt");
    obj<<name<<"\n";
    obj<<age<<"\n";
    obj.close();
    ifstream obj1("1.txt");
    char str[20];
    int x;
    obj1>>str;
    obj1>>x;
    obj1.close();
    cout<<"NAME= "<<str<<endl;
    cout<<"AGE= "<<x<<endl;
    return 0;
}

MULTIPLE INHERITANCE

#include<iostream>
using namespace std;
class employee
{
protected:
    char name[20];
    int id;
public:
    void getdata()
    {
        cout<<"ENTER NAME AND ID"<<endl;
        cin>>name>>id;
    }
};
class salary
{
protected:
    float salaryy;
public:
    void getdata()
    {
        cout<<"ENTER SALARY"<<endl;
        cin>>salaryy;
    }
};
class bonus
{
protected:
    float bonuss;
public:
    void getdata()
{
    cout<<"ENTER BONUS AMOUNT"<<endl;
    cin>>bonuss;
}
};
class total: public employee, public salary, public bonus
{
    protected:
    int totall;
public:
    void getdata()
{
    totall=salaryy+bonuss;
        cout<<"NAME= "<<name<<endl;
    cout<<"ID = "<<id<<endl;
    cout<<"SALARY = "<<salaryy<<endl;
    cout<<"BONUS= "<<bonuss<<endl;
    cout<<"TOTAL SALARY= "<<totall<<endl;
}
};
int main()
{
    total s1;
    s1.employee::getdata();
    s1.salary::getdata();
    s1.bonus::getdata();
    s1.total::getdata();
    return 0;
}

BASIC TO CLASS TYPE

#include<iostream>
using namespace std;
class sample
{
    int hr,mn;
public:
    sample()
    {

    }
    sample(int x)
    {
       hr=x/60;
       mn=x%60;
    }
    void display()
    {
cout<<"hour= "<<hr<<endl;
cout<<"minute= "<<mn<<endl;
    }
};
int main()
{
    int x;
    cout<<"Enter duration"<<endl;
    cin>>x;
    sample s1;
    s1=x;
    s1.display();
return 0;
}

BINARY == OVERLOADING USING FRIEND FUNCTION

#include<iostream>
using namespace std;
class sample
{
    int a;
public:
    void getdata()
    {
        cout<<"ENTER VALUE"<<endl;
        cin>>a;
    }
    void display()
    {
        cout<<"VALUE = "<<a<<endl;
    }
    friend int operator==(sample &obj1, sample &obj2);
};
int operator==(sample &obj1,sample &obj2)
{
    if(obj1.a==obj2.a)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
int main()
{
    sample s1,s2;
    s1.getdata();
    s2.getdata();
    if(s1==s2)
    {
        cout<<"BOTH VALUE IS EQUAL"<<endl;
    }
    else
    {
        cout<<"VALUE ARE NOT EQUAL"<<endl;
    }
    return 0;
}

BINARY * OVERLOADING USING MEMBER FUNCTION

#include<iostream>
using namespace std;
class sample
{
    int a;
public:
    void getdata()
    {
        cout<<"ENTER NUMBER"<<endl;
        cin>>a;
    }
    void display()
    {
        cout<<"VALUE = "<<a<<endl;
    }
    sample operator *(sample &obj)
    {
       sample temp;
       temp.a=a*obj.a;
       return temp;
    }
};
int main()
{
sample s1,s2,s3;
s1.getdata();
s2.getdata();
s1.display();
s2.display();
s3=s1*s2;
s3.display();
return 0;
}

DECREMENT OPERATOR OVERLOADING

#include<iostream>
using namespace std;
class decrement
{
    int a,b;
public:
    void getdata(int x, int y)
    {
    a=x;
    b=y;
    }
    void display()
{
    cout<<"DECREMENT VALUE OF A = "<<a<<endl;
    cout<<"DECREMENT VALUE OF B = "<<b<<endl;
}
    friend void operator--(decrement &obj);
};
void operator--(decrement &obj)
{
    --obj.a;
    --obj.b;
}

int main()
{
    decrement s;
    s.getdata(6,7);
    --s;
    s.display();
}

DYNAMIC INITILIZATION OF OBJECT INCLUDING CONSTRUCTOR

#include<iostream>
using namespace std;
class simple
{
    int p,t,r;
public:
    simple(int x, int y, int z)
    {
        p=x;
        t=y;
        r=z;
    }
    void display()
    {
        int result=(p*t*r)/100;
        cout<<"SIMPLE INTEREST IS "<<result<<endl;
    }
};
int main()
{
    int x,y,z;
    cout<<"ENTER PRINCIPLE, TIME AND RATE "<<endl;
    cin>>x>>y>>z;
    simple s1(x,y,z);
    s1.display();
    return 0;

}

FRIEND FUCNTION TO FIND GREATER NUMBER

#include<iostream>
using namespace std;
class XYZ;
class ABC
{
    int x;
public:
    void getx()
    {
        cout<<"ENTER VALUE OF X"<<endl;
        cin>>x;
    }
    friend void greaterr(ABC,XYZ);
};
class XYZ
{
    int y;
public:
    void gety()
    {
        cout<<"ENTER VALUE OF Y "<<endl;
        cin>>y;
    }
    friend void greaterr(ABC,XYZ);
};
void greaterr(ABC obj1, XYZ obj2)
{
    if(obj1.x>obj2.y)
    {
        cout<<"X is greater"<<endl;
    }
    else
    {
        cout<<"Y is greater"<<endl;
    }
}
int main()
{
    ABC obj1;
    XYZ obj2;
    obj1.getx();
    obj2.gety();
    greaterr(obj1,obj2);
    return 0;
}

OBJECT AS FUNCTION ARGUMENT

#include<iostream>
using namespace std;
class sample
{
    int minute,hour, second;
public:
    void getdata()
    {
        cout<<"ENTER TIME IN MINUTE"<<endl;
        cin>>minute;
    }
    void display(sample s1, sample s2)
    {
        minute=s1.minute+s2.minute;
        hour=minute/60;
        minute=minute%60;
        cout<<"total duration is "<<hour<<" hour "<<minute<<" minute. "<<endl;
    }
};
int main()
{
    sample s1,s2,s3;
    s1.getdata();
    s2.getdata();
    s3.display(s1,s2);
return 0;
}

STATIC DATA MEMBER AND STATIC MEMBER FUNCTION

#include<iostream>
using namespace std;
class sample
{
    char name[20];
    int age;
    static int section;
public:
    void getdata()
    {
        cout<<"ENTER NAME AND AGE"<<endl;
        cin>>name>>age;
    }
    static void getdata1()
    {
        cout<<"Enter section"<<endl;
        cin>>section;
    }
    void display()
    {
        cout<<"name= "<<name<<endl;
        cout<<"age= "<<age<<endl;
    }
    static void display1()
    {
    cout<<"section= "<<section<<endl;
    }

};
int sample :: section;
int main()
{
    sample s1,s2;
    s1.getdata();
    s2.getdata();
    sample :: getdata1();
s1.display();
sample :: display1();
s2.display();
sample :: display1();
    return 0;
}

TOWER OF HANOI USING RECURSION

#include<iostream>
using namespace std;
int tower(int, char,char , char);
int main()
{
    int num;
cout<<"ENTER NO OF DISK"<<endl;
cin>>num;
tower(num,'A','B','c');
}
int tower(int num, char beg, char aux, char End)
{
    if(num>0)
    {
        tower(num-1,beg,End,aux);
        cout<<beg<<" -> "<<End<<endl;
        tower(num-1,aux,beg,End);
    }
    return 0;
}

FACTORIAL USING RECURSION

#include<iostream>
using namespace std;
int fact(int);
int main()
{
    int num;
    cout<<"ENTER NUMBER"<<endl;
    cin>>num;
    cout<<"Factorial is "<<fact(num)<<endl;
    return 0;
}
int fact(int num)
{
    if(num==1 || num==0)
    {
        return 1;
    }
    else
    {
        return num*fact(num-1);
    }
}

FUNCTION OVERLOADING

#include<iostream>
using namespace std;
int volume(int);
int volume(int, int , int);
int volume(int, int);
int main()
{
    int s,l,b,h1,h2,r;
    cout<<"Enter side of cube"<<endl;
    cin>>s;
    volume(s);
    cout<<"Enter radius and height of cylinder"<<endl;
    cin>>r>>h1;
    volume(r,h1);
    cout<<"enter length, breadth and height of cuboid"<<endl;
    cin>>l>>b>>h2;
    volume(l,b,h2);
    return 0;
}
int volume(int s)
{
int result1=s*s*s;
cout<<"volume of cube is "<<result1<<endl;
return 0;
}
int volume(int r,int h1)
{
    int result2=3.14*r*r*h1;
    cout<<"Volume of cylinder is "<<result2<<endl;
    return 0;
}
int volume(int l, int b, int h2)
{
    int result3=l*b*h2;
    cout<<"volume of cuboid is "<<result3<<endl;
    return 0;
}

DEFAULT ARGUMENT

#include<iostream>
using namespace std;
int interest(int , int,int r=5);
int main()
{
    int p,t;
    cout<<"Enter principle and time "<<endl;
    cin>>p>>t;
    interest(p,t);
    return 0;
}
int interest(int p, int t, int r)
{
    int si=(p*t*r)/100;
    cout<<"Simple Interest is "<<si<<endl;
return 0;
}

INLINE FUNCTION

#include<iostream>
using namespace std;
inline int Square(int l)
{
    int s=l*l;
    return s;
}
inline int Cube(int l)
{
    int s1=l*l*l;
    return s1;
}
int main()
{
    int l;
    cout<<"Enter side"<<endl;
    cin>>l;
    cout<<"Square is "<<Square(l)<<endl;
    cout<<"Cube is "<<Cube(l)<<endl;
    return 0;
}

Wednesday, November 25, 2015

JQUERY PROGRAM TO CHANGE COLOR OF TEXT WHEN USER CLICK ON BUTTON

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("#id1").click(function()
{
$(".cl1").css("color","blue");
});
$("#id2").click(function()
{
$(".cl1").css("color","green");
});
$("#id3").click(function()
{
$(".cl1").css("color","red");
});
});
</script>
<body><p class="cl1">
<span style="border: 5px groove cyan"> Click on button to change my color</span>
</p><br>
<br>
<button id="id1">Blue</button>
<button id="id2">Green</button>
<button id="id3">Red</button>
</body>
</html>

Monday, November 23, 2015

JQUERY TO HIDE TEXT WHEN CLICK ON BUTTON AND TO SHOW WHEN DOUBLE CLICK ON BUTTON

<html>
<head>
<script src="jquery-2.1.4.min.js"></script>
<script>
$(document).ready(function()
{
$("#id1").click(function()
{
$(".class1").hide();
});
$("#id2").click(function()
{
$(".class2").hide();
});
$("#id3").click(function()
{
$(".class3").hide();
});
$("#id3").dblclick(function()
{
$(".class3").show();
});
$("#id2").dblclick(function()
{
$(".class2").show();
});
$("#id1").dblclick(function()
{
$(".class1").show();
});
});
</script>
</head>
<body>
<h1 class="class1">Click frist button to hide me</h1><br>
<h2 class="class2">click second button to hide me</h2><br>
<h3 class="class3">click third button to hide me</h3><br>
<button id="id1">First</button>
<button id="id2">Second</button>
<button id="id3">Third</button>
</body>
</html>

Sunday, November 22, 2015

MULTIPLE INHERITANCE

#include<iostream>
using namespace std;
class sample
{
    protected: int x;
    public: void getx()
    {
        cout<<"Enter value of x"<<endl;
        cin>>x;
    }
};
class sample1
{
protected:
    int y;
public:
    void gety()
    {
        cout<<"Enter value of y"<<endl;
        cin>>y;
    }
};
class sample2: public sample, public sample1
{
    int result;
public:
    void multiply()
    {
        result=x*y;
        cout<<"Result is: "<<result<<endl;
    }
};
int main()
{
    sample2 s;
    s.getx();
    s.gety();
    s.multiply();
    return 0;
}

Thursday, November 12, 2015

GREATEST AND SMALLEST ELEMENT IN 2D ARRAY

<html>
<head><title> Greatest and Smallest in 2d array</title>
</head>
<body>
<script language="javascript">
var i,j,greatest,smallest;
var num= new Array(2);
for(i=0;i<2;i++)
{
num[i]=new Array(3);
}
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
num[i][j]=parseInt(prompt("Enter the element",0));
}
}
greatest=num[0][0];
smallest=num[0][0];
document.write("Number you have entered are:<br>");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
document.write(num[i][j]+"<br>")
if(greatest<num[i][j])
{
greatest=num[i][j];
}
if(smallest>num[i][j])
{
smallest=num[i][j];
}
}
}
document.write("Greatest element is "+greatest);
document.write("<br>Smallest element is "+smallest);
</script>
</body>
</html>

Wednesday, November 4, 2015

JAVASCRIPT==COMPARE TWO NUMBER USING DIALOG BOX AND RETURN STATEMENT

<html>
<head>
<script language="javascript">
function compare(a,b)
{
if(a>b)
{
return a;
}
else
{
return b;
}
}
</script>
</head>
<body>
<script language="javascript">
var x=parseInt(prompt("Enter first value",0));
var y=parseInt(prompt("Enter second value",0));
alert("Greater is "+compare(x,y));
</script>
</body>
</html>

CALCULATE EXPONENT OF GIVEN NUMBER BY USING TEXT BOX

<html>
<head>
<script    language="javascript">
function calculate(a,b)
{
var i,c=1;
for(i=0;i<b;i++)
{
c*=a;
}
f1.t3.value=c;
}
</script>
<body>
<form name="f1">
<label>number</label><input type="text" name="t1" value="0"><br>
<label>expontional</label><input type="text" name="t2" value="0"><br>
<label>number</label><input type="text" name="t3" value="0"><br>
<input type="button" value="calculate"onclick="calculate(f1.t1.value,f1.t2.value)">
<input type="reset" value="clear">
</form>
</body>
</html>

JAVASCRIPT==SUM OF ELEMENT OF 2D ARRAY

<html>
<body>
<script language="javascript">
var a= new Array(2);
var sum=0;
for(var i=0;i<a.length;i++)
{
a[i] = new Array(3);

}
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
a[i][j]=parseInt(prompt("Enter element",0));
}
}
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
sum+=a[i][j]
document.write(a[i][j]+"&nbsp;&nbsp;");
}
document.write("<br>");
}
document.write("Total sum of element is "+sum);
</script>
</body>
</html>

Thursday, October 15, 2015

EXAMPLE FOR PARAMETERIZED CONSTRUCTOR

#include<iostream>
using namespace std;
class sample
{
int p,t,r;
public:
    sample(int x, int y, int z)
    {
        p=x;
        t=y;
        r=z;
    }
    void calculate()
    {
    int result=(p*t*r)/100;
    cout<<"The simple interest is "<<result<<endl;
    }
};
int main()
{
sample s1(500,5,2); //parameterized constructor
s1.calculate();
sample s2(300,6,4);
s2.calculate();
sample s3(s1); //copy of constructor is done
s3.calculate(); //it will print same value as object of s1
return 0;
}

Wednesday, October 7, 2015

SAMPLE PROGRAM FOR PARAMETERIZED CONSTRUCTOR IN C++

#include<iostream>
using namespace std;
class sample
{
    int a,c;
public:
    sample(int l, int b)
    {
        a=l;
        c=b;
    }
void area()
{
    int result=a*c;
    cout<<"area of rectangle is "<<result<<endl;
}
};
int main()
{
    sample s(3,5);
    s.area();
    return 0;
}

SAMPLE PROGRAM FOR CONCEPT OF CONSTRUCTOR IN C++

#include<iostream>
#include<iomanip>
using namespace std;
class sample
{
    int l,b;
public:
    sample()
    {
        l=5;
        b=3;
    }
    void area()
    {
        int result=l*b;
        cout<<"Area of rectangle is"<<setw(15)<<result<<endl;
    }
};
int main()
{
    sample s;
    s.area();
    return 0;
}

Tuesday, September 22, 2015

EXAMPLE FOR FRIEND FUNCTION IN C++

#include<iostream>
using namespace std;
class sample
{
    int a,b;
public:
    void getdata()
    {
        cout<<"Enter the value of a and b"<<endl;
        cin>>a>>b;
    }
    friend int mean(sample s)
    {
        int m=(s.a+s.b)/2;
        return m;
    }
};
int main()
{
    sample s;
    s.getdata();
    cout<<" mean = "<<mean(s);
return 0;
}

SUM OF DISTANCE BY PASSING OBJECT AS ARGUMNET IN C++

#include<iostream>
using namespace std;
class distancee
{
    int km,m,cm;
public:
    void getdata();
    void sum(distancee, distancee);
};
void distancee :: getdata()
{
    cout<<"Enter the kilometer"<<endl;
    cin>>km;
    cout<<"Enter the meter"<<endl;
    cin>>m;
    cout<<"Enter the centimeter"<<endl;
    cin>>cm;
}
void distancee :: sum(distancee d1, distancee d2)
{
    cm=d1.cm+d2.cm;
    m=cm/100;
    cm%=100;
    m=m+d1.m+d2.m;
    km=m/1000;
    m%=1000;
    km=km+d1.km+d2.km;
    cout<<"total distance is "<<endl;
cout<<km<<" km "<<m<<" m "<<cm<<" cm "<<endl;
}
int main()
{
    distancee d1,d2,d3;
    d1.getdata();
    d2.getdata();
    d3.sum(d1,d2);
    return 0;
}

CALCULATING TIME BY PASSING ONJECT AS THE FUNCTION ARGUMENT

#include<iostream>
using namespace std;
class time
{
    int hour, minute, second;
public:
    void getdata()
    {
        cout<<"Enter the hour"<<endl;
        cin>>hour;
        cout<<"Enter the minute"<<endl;
        cin>>minute;
        cout<<"Enter the second"<<endl;
        cin>>second;
    }
    void display(time t1, time t2)
    {
        second=t1.second+t2.second;
        minute=second/60;
        second%=60;
        minute=minute+t1.minute+t2.minute;
        hour=minute/60;
        minute%=60;
        hour=hour+t1.hour+t2.hour;

        cout<<"The total time is "<<endl;
        cout<<hour<<" hour "<<minute<<" minute "<<second<<" second "<<endl;
    }
};
int main()
{
    time t1,t2,t3;
    t1.getdata();
    t2.getdata();
    t3.display(t1,t2);
    return 0;
}

Monday, September 7, 2015

FIBONICCI SERIES USING RECURSION IN C++

#include<iostream>
using namespace std;
int fibo(int, int, int);
int main()
{
    int n;
    cout<<"Enter the number"<<endl;
    cin>>n;
    fibo(0,1,n);
return 0;
}
int fibo(int a, int b, int n)
{
    int c;
    if(n==0)
    {
        return 0;
    }
    else{
        cout<<a<<"\t";
        c=a+b;
        a=b;
        b=c;
    return fibo(a,b,(n-1));
    }
}

FUNCTION OVERLOADING SAMPLE PROGRAM

#include<iostream>
using namespace std;
int volume(int);
int volume(int, int, int);
void volume(float, float);
int main()
{
    int s;
    cout<<"Enter size of cube"<<endl;
    cin>>s;
    cout<<"Volume of cube is "<<volume(s)<<endl;
    int l,b,h;
    cout<<"Enter the length, height and width of cuboid"<<endl;
    cin>>l>>b>>h;
    cout<<"Volume of cuboid is "<<volume(l,b,h)<<endl;
    float r,h1;
    cout<<"Enter the radius and height of cylinder"<<endl;
    cin>>r>>h1;
    volume(r,h1);
    return 0;
}
int volume(int l)
{
    return l*l*l;
}
int volume(int l,int b,int h)
{
    return (l*b*h);
}
void volume(float r, float h)
{
    float result;
    result=3.14*r*r*h;
    cout<<"Volume of cylinder is "<<result<<endl;
}

FIBONICCI SERIES USING RECURSION IN C++

#include<iostream>
using namespace std;
int fibo(int, int, int);
int main()
{
    int n;
    cout<<"Enter the number"<<endl;
    cin>>n;
    fibo(0,1,n);
return 0;
}
int fibo(int a, int b, int n)
{
    int c;
    if(n==0)
    {
        return 0;
    }
    else{
        cout<<a<<"\t";
        c=a+b;
        a=b;
        b=c;
    return fibo(a,b,(n-1));
    }
}

Friday, September 4, 2015

COUNT TOTAL NO. OF DIGIT AND EVEN DIGIT PRESENT IN NUMBER

#include<iostream>
using namespace std;
int main()
{
    int num,rem,c=0,dig=0;
    cout<<"Enter the number"<<endl;
cin>>num;
while(num>0)
{
    rem=num%10;
    c++;
    if(rem%2==0)
    {
        dig++;
    }
    num/=10;
}
cout<<"number of digit present is "<<c<<endl;
cout<<"number of even digit present is "<<dig<<endl;
return 0;
}

TAKE INPUT AND DISPLAY DETAIL OF EMPLOY USING CLASS IN C++

#include<iostream>
using namespace std;
class employ
{
    char name[20];
    int id;
    double salary;
public:
    void getdata();
    void display();
};
void employ :: getdata()
{
    cout<<"Enter the name of the employ"<<endl;
    cin>>name;
    cout<<"Enter the ID of employ"<<endl;
    cin>>id;
    cout<<"Enter the salary of the employ"<<endl;
    cin>>salary;
}
void employ :: display()
{
    cout<<name<<"\t"<<id<<"\t"<<salary<<endl;
}
int main()
{
    employ a,b;
    a.getdata();
    b.getdata();
    cout<<"\nNAME\t"<<"ID\t"<<"SALARY"<<endl;
    a.display();
    b.display();
return 0;
}

Monday, May 18, 2015

TO DISPLAY NUMBER OF OCCURRENCE OF LETTER OF GIVEN STRING

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char string[50];
    int count[26],i,j=0,alpha[26],m;
    char letter=97;
    printf("enter the string\n");
    gets(string);
    strlwr(string);
    for(m=0;m<26;m++)
    {
        count[m]=0;
        i=0;
    while(string[i]!=NULL)
    {
        alpha[m]=letter;
        if(alpha[m]==string[i])
        {
            count[m]++;
        }
        i++;
    }
    letter++;
    }
    printf("\nalphabet\t\t\toccurrence\n");
    for(m=0;m<26;m++)
    {
        if(count[m]!=0)
        {
            printf("%c\t\t\t\t%d\n",alpha[m],count[m]);
        }
    }
}

Monday, May 4, 2015

8085 MPU PROGRAM TO PERFORM EXPRESSION DAH-(59H+44H)

MVI A 59h
MVI B 44h
ADD B
DAA
MOV C A
MVI A DAh
SBB C
DAA
STA 3000h

8085 MPU PROGRAM TO PERFORM 16 ADDITION USING 8 BIT METHOD

LXI H 5492h
XCHG
LXI H A5B6h
MOV A L
ADD E
STA 1001h
MOV A H
ADC D
STA 1000h

Please kindly create a 1000h and 1001h address in user grid  so that result can be store in it.

8085 MPU PROGRAM TO MULTIPLY 17H AND 04 AND AND STORE RESULT IN 2000H ADDRESS

MVI A 00h
MVI C 04h
MVI B 17h
LOOP: ADC B
DAA
DCR C
JNZ LOOP
STA 2000h
HLT

Please kindly create a 2000h address in user grid table so that result will be store in 2000h address

8085 MPU PROGRAM TO SOLVE THE EXPRESSION A7H-83H+17H AND STORE RESULT IN 2000H ADDRESS

MVI A A7h
MVI B 83h
MVI C 17h
SUB B
DAA
ADC C
DAA
STA 2000h

Please create the address 2000h in usergrid so that it can store the result in 2000h address

8085 MPU PROGRAM TO EXCHANGE THE VALUE OF TWO REGISTER USING SUBROUTINE CONCEPT

MVI B 05h
MVI C 08h
CALL SWAP
HLT
SWAP: MOV D B
MOV B C
MOV C D
RET

8085 MPU PROGRAM TO FIND THE SMALLEST NUMBER FROM GIVEN ARRAY ELEMENT

LXI H 1000h
MVI C 05h
MOV A M
LOOP: INX H
CMP M
JC SMALLEST
MOV A M
SMALLEST: DCR C
JNZ LOOP
STA 2000h
HLT

Please fill the usergrid which is starting from 1000h to 1006h and input the value to find the smallest number from the given value and don't forget to make 2000h location also so, that smallest number will be store in 2000h location.

8085 MPU PROGRAM TO FIND LARGEST NUMBER FROM GIVEN ARRAY ELEMENT

LXI H 1000h
MVI C 05h
MOV A M
LOOP: INX H
CMP M
JNC GREATER
MOV A M
GREATER: DCR C
JNZ LOOP
STA 2000h
HLT

Please fill the user grid which begin from 1000h to 1006h and insert the value to find the largest number.

Sunday, May 3, 2015

SORTING OF STRING IN ASCENDING ORDER USING C PROGRAM

#include<stdio.h>
#include<conio.h>
void main()
{
    char name[10][20],temp[20];
    int i,j,n;
    printf("how many string you want to enter\n");
    scanf("%d",&n);
    printf("enter the strings\n");
    for(i=0;i<=n;i++)
    {
gets(name[i]);
strlwr(name[i]);
  }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
         if((strcmp(name[j],name[j+1])==1))
            {
                strcpy(temp,name[j]);
                strcpy(name[j],name[j+1]);
                strcpy(name[j+1],temp);
            }
        }

    }
    printf("sorted form of data are:\n");
    for(i=0;i<=n;i++)
    {
        printf("%s\n",name[i]);
    }



}

C PROGRAM TO REVERSE THE NUMBER

#include<stdio.h>
#include<conio.h>
void main()
{
    int n,rem,rev=0;
    printf("enter the number\n");
    scanf("%d",&n);
    while(n>0)
    {
        rem=n%10;
        rev=rev*10+rem;
        n=n/10;
    }
    printf("the reverse of the number is %d",rev);
}

C PROGRAM TO DELETE NUMBER FROM IT LOCATION IN ARRAY

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[]={1,2,4,5,6,74,32};
 int position,i;
 printf("the number are:\n");
 for(i=0;i<7;i++)
 {
     printf("%d\t",a[i]);
 }
 printf("\nenter the position to delete\n");
 scanf("%d",&position);
 for(i=position;i<=7;i++)
 {
     a[i-1]=a[i];
 }
 printf("\nthe data after deletion is:\n");
 for(i=0;i<6;i++)
 {
     printf("%d\t",a[i]);
 }
}

C PROGRAM TO PRINT PRIME NUMBER BETWEEN 1 TO 500

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,c;
    for(i=1;i<=500;i++)
    {
        c=0;
        for(j=1;j<=i;j++)
        {
            if(i%j==0)
            {
                c++;
            }
    }
    if(c==2)
            {
                printf("%d\t",i);
            }
}
}

Wednesday, April 29, 2015

SORTING OF NUMBER IN DESCENDING ORDER USING SELECTION SORT METHOD IN C PROGRAM

#include<stdio.h>
#include<conio.h>
void main()
{
    int a[20],i,j,n,temp;
    printf("enter the limit n\n");
    scanf("%d",&n);
    printf("enter the %d numbers\n",n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]<a[j])
            {
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
            }
        }
    }
    printf("the sorted data are:\t");
    for(i=0;i<n;i++)
    {
        printf("%d\t",a[i]);
    }

}

TO FIND OUT SUM OF DIAGONAL ELEMENT OF MATRIX USING C PROGRAM

#include<stdio.h>
#include<conio.h>
void main()
{
    int a[2][2],i,j,sum=0;
    printf("enter the matrix:\n");
    for(i=0;i<2;i++)
    {
        for(j=0;j<2;j++)
        {
            scanf("%d",&a[i][j]);
            printf("\t");
        }
        printf("\n");
    }
    for(i=0;i<2;i++)
    {
        for(j=0;j<2;j++)
    {
        if(i==j)
        {
            sum+=a[i][j];
        }
    }
     }
printf("the sum of diagonal element of matrix is %d",sum);
}

C PROGRAM TO FIND THE TRANSPOSE OF GIVEN 2X2 MATRIX

#include<stdio.h>
#include<conio.h>
void main()
{
    int a[2][2],i,j;
    printf("enter the matrix:\n");
    for(i=0;i<2;i++)
    {
        for(j=0;j<2;j++)
        {
            scanf("%d",&a[i][j]);
            printf("\t");
        }
        printf("\n");
    }
    printf("the transpose of matrix is:\n");
    for(i=0;i<2;i++)
    {
        for(j=0;j<2;j++)
    {
        printf("%d\t",a[j][i]);
    }
    printf("\n");
    }
}

Thursday, April 23, 2015

C PROGRAM TO SWAP NUMBER BY PASSING POINTER TO FUNCTION

#include<stdio.h>
#include<conio.h>
int swap(int **c,int **d);
void main()
{
    int a,b,*c,*d;
    printf("enter the value\n");
    printf("a=");
    scanf("%d",&a);
    printf("\nb=");
    scanf("%d",&b);
    c=&a;
    d=&b;
    swap(&c,&d);
}
int swap(int **c,int **d)
{
    **c=**c+**d;
    **d=**c-**d;
    **c=**c-**d;
    printf("after swapping\n");
    printf("a=%d",**c);
    printf("\nb=%d",**d);
    return 0;
}

Saturday, April 18, 2015

C PROGRAM USING MACRO TO FIND AREA OF CIRCLE

#include<stdio.h>
#include<conio.h>
#define pie 3.14
#define circle(pie,r) (pie*r*r)
void main()
{
    float r,a;
    printf("enter the radius:\t");
    scanf("%f",&r);
    a=circle(pie,r);
    printf("the area of circle is %f",a);
getch();
}

C PROGRAM TO KNOW ASCII VALUE OF KEY WHICH YOU HAVE ENTERED

#include<stdio.h>
#include<conio.h>
void main()
{
    char a,b;
    do{
    printf("Enter the key which you want to know ASCII value\t");
a=getch();
    printf("\n\nthe ASCII value of key you have entered is: %d",a);
    printf("\n\nwant to know more 'y' for yes, 'n' for no(Y/N)\n\n");
    b=getch();
    }while(b=='y' || b=='Y');
getch();
}

Tuesday, April 14, 2015

C PROGRAM TO READ THE DATA FROM THE FILE

#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fp;
    char *p,data[20];
    fp=fopen("file.txt","r");
    while((p=fgets(data,40,fp))!=NULL)
    {
        printf("%s\n",data);
    }
    fclose(fp);
}

C PROGRAM FOR FILE HANDLING TO WRITE DATA IN FILE

#include<stdio.h>
#include<conio.h>
struct student
{
    char name[20];
    int age;
    int mark;
};
void main()
{
    FILE *fp;
    int i,n;
    char name[20];
    fp=fopen("file.txt","w");
    printf("how many data you want to store\n");
    scanf("%d",&n);
    struct student s[20];
    for(i=0;i<n;i++)
    {
    printf("name%d=\t",i+1);
    scanf("%s",s[i].name);
    fprintf(fp,"%s\t",s[i].name);
    printf("age%d=\t",i+1);
    scanf("%d",&s[i].age);
    fprintf(fp,"%d\t",s[i].age);
    printf("mark%d=",i+1);
    scanf("%d",&s[i].mark);
    fprintf(fp,"%d\n",s[i].mark);
    }
    fclose(fp);
}

Saturday, April 11, 2015

C PROGRAM CODE FOR HOTEL BILL

#include<stdio.h>
#include<conio.h>
#include<windows.h>
void bill(char name[], char add[], int o[],char *s[],int p[]);
void main()
{
int i,o[10],p[]={40,60,55,85,95,90,130,25,20,10};
char *s[]={"Rice       ","Fried Rice  ","Sahi Paneer  ","Chicken Kosa  ","Chicken Kabab","Chilli Chicken","Mutton Kosa","Salad       ","Soft Drinks","Sweets        "};
char name[20],add[20];
char a,b;
printf("\t ****************WELCOME TO HOTEL LOVELY***************** \n");
printf("\t\t\tNH-1, PHAGWARA, PUNJAB\n");
printf("\t\t\t MOBILE-+91-9872300000\n");
printf("\n\t Enter Your Name:\t ");
gets(name);
printf("\t Enter Your Address:\t");
gets(add);
printf("\n\t **** DEAR CUSTOMER, TODAY WE HAVE SPECIALY ITEM FOR YOU ****\n\n");
printf(" \t ITEMS \t\t\t PRICE\n");
for(i=0;i<10;i++)
{
printf(" %d. %s \t\t %d (Per Plate)\n",i+1,s[i],p[i]);
}
printf("\nDear customer, would you like to give order?(y for yes/ n for no) : ");
scanf("%c",&a);
if(a=='y'||a=='Y')
{
printf("\n\t Your Order ......");
printf("\n \t Please Select Your Order(Enter Quantity only):\n");

for(i=0;i<10;i++)
{
printf("\n  %d  \t   %s   \t\t   :\t",i+1,s[i]);
scanf("%d",&o[i]);
}
printf("\n\n \t In 10 Minutes, food will be on the Table");
printf("\n \t Please Wait....!\n");
printf("\n\n\n\t Want bill, Sir...?(y for yes)\t:\t ");
scanf(" %c",&b);

if(b=='y'||b=='Y')
{
   bill(name,add,o,s,p);
   }
}
printf("\n\n\n\t\t Thank You Sir, Visit Again...!");
printf("\n___________________________________________________DEVELOPED BY BIKASH THAPA\n");
}
void bill(char name[], char add[], int o[],char *s[],int p[])
   {
       int i,tot=0;
       system("cls");
       printf("\n\t******************WELCOME TO HOTEL LOVELY********************* \n");
printf("\t\t\t NH-1, PHAGWARA, PUNJAB\n");
printf("\t\t\t MOBILE-+91-9872350000\n");
printf("\n\t Customer Name: \t");
puts(name);
printf("\t Customer Address: \t");
puts(add);
printf("\n\t Your Today's Bill is.....\n");
printf(" \t\t\t    ITEMS       \t\t\t\t TOTAL");
printf("\n\t____________________________________________________________________");
for(i=0;i<10;i++)
{
if(o[i]!=0)
{
printf("\n\t\t    %s    \t(%d X %d)\t\t    %d",s[i],o[i],p[i],o[i]*p[i]);
}
}
printf("\n\t____________________________________________________________________");
for(i=0;i<10;i++)
{
tot=tot+o[i]*p[i];
}
printf("\n\t Your Total Billing amount is\t:\t\t\t    %d\n",tot);
}

Friday, April 10, 2015

C PROGRAM FOR QUIZ

#include<stdio.h>
#include<conio.h>
void main()
{
    int counter;
    char name[10],z,b,x,w;
    printf("*******************************************************************************\n");
        counter=0;
    printf("-----*********************WELCOME TO QUIZ CONTEST ***********************------\n");
    printf("\t           IF YOU WANT TO PLAY QUIZ THEN PRESS 'Y'\n");
    b=getch();
    if(b=='y' || b=='Y')
    {
        do
    {
        printf("\nENTER YOUR NAME? \n");
        scanf("%s",name);
        printf("\nHey %s, You are most welcome to our quiz contest.\n",strupr(name));
        printf("-------------------------------------------------------------------------\n");
        printf("PLEASE READ RULES AND INSTRUCTION CAREFULLY BEFORE ATTENDING TO QUIZE: \n");
        printf("-------------------------------------------------------------------------\n");
        printf("Press 'a' if answer of 'a' is correct.\nPress 'b' if answer of 'b' is correct.\nPress 'c' if answer of 'c' is correct.\nPress 'd' if answer of 'd' is correct.\nIf you press any key beside a or b,\nor c or d,then answer is counted as wrong.\n");
        printf("If you have completed by reading rules and instruction.\n");
        printf("------------------------PRESS 'C' TO CONTINUE----------------------------------");
        x=getch();
        if(x=='c' || x=='C')
        {
               printf("\n------------------FINALLY QUESTION GOES HERE:------------------------\n");
               printf("****************************BEST OF LUCK*******************************\n");
               printf("-------------------------------------------------------------------------");
               printf("\n\n1.Who is knowns father of computer science? \n");
               printf("a.Charles Babbage\t b.Mahatma Gandhi\nc.Bill grates     \t d.Lady Ada ");
                      z=getch();
                      switch(z)
                      {
                          case 'a':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }

                      printf("\n\n2.Who is known as light of Asia?");
               printf("\na.Charles Babbage\t b.Mahatma Gandhi\nc.Bill grates     \t d.Gautam Buddha ");
                    z=getch();
                      switch(z)
                      {
                          case 'd':
                            printf("\n************correct************");
                            counter=counter+1;
                            break;
                          default:
                            printf("\n*************wrong**************");
                            break;
                      }
                         printf("\n\n3.'OS' computer abbreviation usually means ?\n");
               printf("a.operating shutdown\t b.open software\nc.operating system \t d.optical sensor");
                      z=getch();
                      switch(z)
                      {
                          case 'c':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n4.'.MOV' extension refers usually to what kind of file?\n");
               printf("a.Image file\t b.Animation/Movie\nc.Audio file\t d.Ms office document");
                      z=getch();
                      switch(z)
                      {
                          case 'b':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n5.Which of the following special symbol allowed in a variable name? \n");
               printf("a.*(asterisk)\t b.|(pipeline)\nc.-(hyphen) \t d._(underscore)");
                      z=getch();
                      switch(z)
                      {
                          case 'd':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n6.By default a real number is treated as a:? \n");
               printf("a.float\t\tb.double\nc.long double \t d.far double");
                      z=getch();
                      switch(z)
                      {
                          case 'b':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n7.Array is the collection of similar:? \n");
               printf("a.data type\tb.variable\nc.constant\t d.data");
                      z=getch();
                      switch(z)
                      {
                          case 'a':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
        printf("\n\n8.Which of the following is not a user defined data types?\n");
               printf("a.int\t\tb.enum\nc.struct\td.union");
                      z=getch();
                      switch(z)
                      {
                          case 'a':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n9.2 byte is equal to:\n");
               printf("a.1 bit\t\tb.16 bit\nc.32 bit\td.8 bit");
                      z=getch();
                      switch(z)
                      {
                          case 'b':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n10.Network of network is known as ?\n");
               printf("a.URL\t\tb.MAN\nc.LAN\t\td.WAN");
                      z=getch();
                      switch(z)
                      {
                          case 'd':
                            printf("\n***********correct************");
                              counter=counter+1;
                              break;

                          default:
                            printf("\n************wrong**************");
                            break;
                      }
                      printf("\n\n%d answer is correct",counter);
    }
                           else
    {
        printf("\n\n**************HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHA********************");
        printf("\n*************|| YOU ARE LOSER READ INSTRUCTION PROPERLY || ****************");
        printf("\n**************************||GET LOST||***********************************");

    }
    if(counter>=8)
    {
        printf("\n****************CONGRATULATION YOU HAVE WON THE QUIZ**********************\n");
    }
    else
    {
        printf("\n********************YOU ARE LOSER || TRY AGAIN***************************\n");
    }
     printf("\n***************Thanks Mr/s. %s for participating in our quiz*************",name);

     printf("\nDO YOU WANT TO TRY AGAIN IF YES THEN PRESS 'Y'");
        w=getch();
    }
while(w=='y' || w=='Y');
}
else
{
printf("\nPlease read instruction properly and try again later\n");
}
printf("\n************************************************DEVELOPED BY MR.BIKASH THAPA");
}

SAMPLE C PROGRAM USING UNION

#include<stdio.h>
#include<conio.h>
union employ
{
    char name[20];
    int age;
    float salary;
};
void main()
{
    union employ e;
    printf("enter the employ name\n");
    gets(e.name);
    printf("%s",e.name);
    printf("\nenter the age\n");
    scanf("%d",&e.age);
    printf("%d",e.age);
    printf("\nenter the salary\n");
    scanf("%f",&e.salary);
    printf("%f",e.salary);
    printf("\nthe size is %d",sizeof(e));
}

COUNT VOWEL, CONSONANT, NUMBER, WHITE SPACE & LENGTH PRESENT IN GIVEN STRING USING C PROGRAM

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char string[100];
int v=0,c=0,w=0,nu=0,n,i;
printf("enter the string\n");
gets(string);
n=strlen(string);
for(i=0;i<n;i++)
{
    if(string[i]=='a'||string[i]=='A'||string[i]=='e'||string[i]=='E'||string[i]=='i'||string[i]=='I'||string[i]=='o'||string[i]=='O'||string[i]=='u'||string[i]=='U')
    {
        v++;
    }
    else if(string[i]>='a' && string[i]<='z' || string[i]>='A' && string[i]<='Z')
    {
        c++;
    }
    else if(string[i]==' ')
    {
        w++;
    }
    else if(string[i]>='0'&& string[i]<='9')
    {
        nu++;
    }
}
printf("total number of word letter present is %d\n",v);
printf("total number of consonant letter present is %d\n",c);
printf("total number of number present is %d\n",nu);
printf("total number of white space present is %d\n",w);
printf("total number of letter present is %d",n);
}

Thursday, April 9, 2015

Thursday, April 2, 2015

C PROGRAM OF STRUCTURE ARRAY TO TAKE DATA AND DISPLAY IT

#include<stdio.h>
#include<conio.h>
struct student
{
    char name[20];
    int roll,age;
};
void stud(struct student s[],int n);
void main()
{
    struct student s[10];
 int i,n;
 printf("how many data you want to print\n");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
    printf("enter the name %d\n",i+1);
    scanf("%s",s[i].name);
    printf("enter the roll no\n");
    scanf("%d",&s[i].roll);
    printf("enter the age\n");
    scanf("%d",&s[i].age);
 }
     stud(s,n);
}
stud(struct student s[],int n)
{
    int i;
    printf("the data you have entered are:\n");
    printf("name\troll no\tage\n");
    for(i=0;i<n;i++)
    {
        printf("%s\t%d\t%d\n",s[i].name,s[i].roll,s[i].age);
    }
}

C PROGRAM TO DISPLAY DATA USING POINTER TO STRUCTURE

#include<stdio.h>
#include<conio.h>
struct student
{
    char name[20];
    int roll,age;
};
void main()
{
    struct student s,*p;
    p=&s;
    printf("enter the name\n");
    scanf("%s",p->name);
    printf("enter the roll no\n");
    scanf("%d",&p->roll);
    printf("enter the age\n");
    scanf("%d",&p->age);
    printf("name\troll no\tage");
    printf("\n%s\t%d\t%d\n",p->name,p->roll,p->age);
}

2D ARRAY SORTING OF COLUMNS AND ROWS

#include<stdio.h>
#include<conio.h>

int main( )
{

    int a[][6]={
                {25,64,96,32,78,27},      //from here begins my Desired solution : {25,27,32,64,78,96},
                {50,12,69,78,32,92}       //                   {50,92,78,12,32,69}
                };
     int i, j, k, temp, temp1 ;

    //
     for(j=1;j<6;j++)
     {
          for(i=0; i<5; i++)
          {
                if(a[0][i]>a[0][i+1])
                {
                    temp=a[0][i];
                    a[0][i]=a[0][i+1];
                    a[0][i+1]=temp;

                    temp1 = a[1][i];
                    a[1][i] = a[1][i+1];
                    a[1][i+1]=temp1;
                }
          }
     }

     printf ( "\n\nArray after sorting:\n") ;
     for ( i = 0 ; i <2; i++ )
     {
        for(j=0; j<6; j++)
        {
            printf ( "%d\t", a[i][j] ) ;        // from here am printing sorted array
        }
        printf("\n");
     }
     getch();
 }

PPT – Malware PowerPoint presentation | free to view

PPT – Malware PowerPoint presentation | free to view

Tuesday, March 24, 2015

C PROGRAM TO PRINT THE PRIME NUMBERS BETWEEN 1 AND N AS USER CHOICE


#include<stdio.h>
#inlcude<conio.h>
void main()
{
int num,i=1,j,count

clrscr();
printf("Enter Number value To Print Prime Numbers between 1 to Num: ");
scanf("%d",&num);
printf("Prime Numbers upto %d :\n \n",num);

while(i<=num)
{
count=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count==2) 
printf("%d ",i);
i++;
}
printf("\n\n");


getch(); 
}

Monday, March 23, 2015

MPU 8085 PROGRAM TO SORT THE NUMBER

MVI B 05h
LOOOP: LXI H 2000h
MVI C 05h
LOOP: MOV A M
INX H
CMP M
JNC JUMP
MOV D M
MOV M A
DCX H
MOV M D
INX H
JUMP: DCR C
JNZ LOOP
DCR B
JNZ LOOOP
HLT

C PROGRAM TO SWAP THE NUMBER USING POINTER

#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b,*x,*y;
    printf("a=");
    scanf("%d",&a);
    printf("\nb=");
    scanf("%d",&b);
    x=&a;
    y=&b;
    *x=*x+*y;
    *y=*x-*y;
    *x=*x-*y;
    printf("after swapping\n");
    printf("a=%d",*x);
    printf("\na=%d",*y);
}

Friday, March 20, 2015

C PROGRAM TO FIND FIBONACCI SERIES USING RECURSIVE FUNCTION

#include<stdio.h>
#include<conio.h>
int fibo(int n, int a,int b);
main()
{
    int n;
    printf("enter the limit number:\n");
    scanf("%d",&n);
    fibo(n,0,1);
}
int fibo(int n, int a,int b)
{
    if(a>n)
    {
        return 0;
    }
    else
        {
            printf("%d\t",a);
        return fibo(n,b,a+b);
        }


    }

C PROGRAM TO FIND THE FACTORIAL OF GIVEN NUMBER USING RECURSIVE FUNCTION

#include<stdio.h>
#include<conio.h>
int fact(int n);
main()
{
int n;
printf("enter the number n:\n");
scanf("%d",&n);
printf("the factorial %d is %d",n,fact(n));
}
int fact(int a)
{
if(a==1)
{
return 1;
}
else
{
return a*fact(a-1);
}
}

C PROGRAM TO CHECK WEATHER THE GIVEN STRING IS PALINDROME OR NOT

#include<stdio.h>
#include<conio.h>
void main()
{
    char word[10],word1[10];
    printf("enter the string\n");
    gets(word);
    strcpy(word1,word);
    if(strcmp(strrev(word),word1)==0)
    {
        printf("%s  is palindrome\n",word1);
            }
            else
            {
     printf("%s is not palindrome\n",word1);
  }
getch();
}

C PROGRAM USING POINTER TO DISPLAY VALUE AND ADDRESS OF VARIABLE

#include<stdio.h>
#include<conio.h>
void main()
{
    int a=5,*b;
    b=&a;
    printf("the value of a= %d\n",a);
    printf("the address of a is: %d\n",b);
    printf("the value of *b is: %d",*b);
    getch();


}

Thursday, March 19, 2015

C PROGRAM TO TAKE ROLL NO, NAME AND MARK OF STUDENT USING NESTED STRUCTURE

#include<stdio.h>
#include<conio.h>
struct student
{
    int roll;
    char name[20];
    struct marks
    {
        int mark;
    }b;
};
void main()
{
    struct student a;
    printf("enter the roll no, name and mark of student\n");
    scanf("%d%s%d",&a.roll,a.name,&a.b.mark);
    printf("the data you have entered are;\n");
    printf("roll no\tname\tmark\n");
    printf("%d\t%s\t%d",a.roll,a.name,a.b.mark);
}

C PROGRAM TO TAKE NAME, ROLL NO AND MARK OF 5 STUDENT AND DISPLAY IT USING ARRAY IN STRUCTURE

#include<stdio.h>
#include<conio.h>
struct student
{
    char name[20];
    int roll;
    int mark;
};
void main()
{
    struct student a[5];
    int i;
    for(i=0;i<5;i++)
    {
        printf("enter name %d, roll no and marks\n",i+1);
        scanf("%s%d%d",a[i].name,&a[i].roll,&a[i].mark);
    }
    printf("the data you have entered are:\n");
    printf("name\troll no\tmark\n");
    for(i=0;i<5;i++)
    {
        printf("%s\t%d\t%d\n",a[i].name,a[i].roll,a[i].mark);
    }

}

C PROGRAM TO ENTER NAME, ROLL NO AND MARK AND DISPLAY IT USING STRUCTURE

#include<stdio.h>
#include<conio.h>
struct student
    {
        char name[20];
        int roll;
        int mark;

    };
void main()
{
    struct student a;
        printf("enter the name, roll no and mark\n");
        scanf("%s%d%d",a.name,&a.roll,&a.mark);
        printf("the data you have entered are:\n");
        printf("name\troll\tmark\n");
        printf("%s\t%d\t%d",a.name,a.roll,a.mark);
}

Monday, March 16, 2015

C PROGRAM TO COUNT THE NUMBER OF LETTER PRESENT IN WORD, FIND THE REVERSE OF WORD & CHECK PALINDROME OR NOT. AND DISPLAY THE CONCATENATE BETWEEN FIRST AND TWO WORD


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char word[20],word1[20],word2[20];
    int n;
    printf("enter the first word\n");
    scanf("%s",word);
    printf("enter the second word\n");
    scanf("%s",word2);
    n=strlen(word);
    strcpy(word1,word);
    printf("the number of letter present in %s is %d\n",word,n);
    printf("the reverse is %s\n",strrev(word1));
    if(strcmp(word,word1)==0)
    {
        printf("%s is palindrome word\n",word);
    }
    else
    {
        printf("%s is not palindrome word\n",word);
    }
    printf("the concatenate of first and second word is %s \n",strcat(word,word2));
    }

FOR MORE PROGRAM CLICK HERE

Saturday, March 14, 2015

C PROGRAM TO PRINT ALL THE PRIME NUMBER UP TO THE LIMIT

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,c,n;
    printf("enter the limit:\n");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i==1)
        {
            printf("%d\t",i);
        }
        else
            {
                c=0;
            for(j=1;j<=i;j++)
            {
                if(i%j==0)
                {
                c=c+1;
                }
            }
             if(c==2)
            {
                printf("%d\t",i);
            }

    }
    }
}

PROGRAM TO REVERSE NUMBER & CHECK WEATHER IT IS PALINDROME OR NOT.

#include<stdio.h>
#include<conio.h>
void main()
{
    int rem,n,dig=0,num;
    printf("enter the number n \n");
    scanf("%d",&n);
    num=n;
    while(n>0)
    {
        rem=n%10;
        dig=dig*10+rem;
        n=n/10;
    }
    printf("the reverse is %d\n",dig);
    if(num==dig)
    {
        printf("it is palindrome");
        }
        else
        {
            printf("it is not palindrome");
        }
    }


C PROGRAM TO SORT NUMBER USING BUBBLE SORT METHOD

#include<stdio.h>
#include<conio.h>
void main()
{
    int n,a[10],temp,i,j;
    printf("enter the limit:\n ");
    scanf("%d",&n);
    printf("enter the numbers to be sorted:\n");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-1;j++)
        {
            if(a[j]>a[j+1])
            {
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
            }
        }
        printf("the sorted form of number using bubble sort are:\n");
        for(i=0;i<n;i++)
        {
            printf("%d\t",a[i]);
        }
    }

C PROGRAM TO PRINT THE HEART SHAPE PATTERN

heart shape

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int a, b, c;
printf("Enter size of heart(<20): \n");
scanf("%d",&c);
for (a=0; a<c; a++)
{
for (b=0; b<=4*c; b++)
{
int d = sqrt( pow(a-c,2) + pow(b-c,2) );
int e = sqrt( pow(a-c,2) + pow(b-3*c,2) );
if (d < c + 0.5 || e < c +0.5 )
printf("*");
else
printf(" ");
}
printf("\n");
}
for (a = 1; a <= 2*c; a++)
{
for (b=0; b<a; b++)
printf(" ");
for (b=0; b<4*c + 1 - 2*a; b++)
printf("*");
printf("\n");
}
return 0;
}