Top Banner

of 50

Computers practical file

Jun 02, 2018

ReportDownload

Documents

ateet

  • 8/10/2019 Computers practical file

    1/50

    To Calculate Sum of Series:

    X2/2! + X4/4! + .->

    #includeiostream.h>#include#includevoid main(){ clrscr(); foat ,a,b,j,s,x,I,n; !; sx"; coutn; or(i!;i

  • 8/10/2019 Computers practical file

    2/50

    To check wether numer is an

    rmstron" numer ->

    #include#include#include

    void main() { clrscr(); int r; lon/ int n,c,sum,tem; nsum"; coutn;

    cout

  • 8/10/2019 Computers practical file

    3/50

    To check whether the

    numer is e#en or o$$ or

    %rime->#include#includevoid main(){ clrscr(); int e; char ch; 7o

    { cout

  • 8/10/2019 Computers practical file

    4/50

    To Calculate Sum of Series:

    X2/2! + X4/4! + .->#includeiostream.h>#include#includevoid main(){ clrscr(); foat ,a,b,j,s,x,I,n; !; sx";

    coutn; or(i!;i

  • 8/10/2019 Computers practical file

    5/50

    To %rint &an$om 'umers ->

    #include#include#includevoid main(){ clrscr(); randomi?e(); int num,rndnum; cin>>num; rndnumrandom(num)!;

    or( int n !;n

  • 8/10/2019 Computers practical file

    6/50

    (ro"ram ase$ on

    Constructor ) *estructor ->#include#includeclass abc{ int a,b; foat c; ublic8 abc();

    abc(int,char); abc(abc&); Babc(); void rint();*abc88abc(){ a!C; bD0D; c!".!'=;*abc88abc(int x,char 0){ ax; b0; c'C.!C;*abc88abc(abc&x){ ax.a; bx.b;

    *Babc88abc(){ cout

  • 8/10/2019 Computers practical file

    7/50

    clrscr(); abc obj!; abc obj'('A,D/D); abc obj=(obj!); obj!.rint();

    obj'.rint(); obj=.rint(); /etch();*

    C

  • 8/10/2019 Computers practical file

    8/50

    (ro"ram ase$ on ,rien$

    ,unction ->#include#[email protected] cmlx!{ int real,ima/in; ublic8 void /et() { cout

  • 8/10/2019 Computers practical file

    9/50

    (ro"ram ase$ on Class $ata

    t%e ->

    #include#[email protected] matrix{ int aHH,bHH,I,j,x,0,sum; ublic8

    void /etvalues(); void disla0sum();*;void matrix88/etvalues(){ cout0; i(x50) { cout

  • 8/10/2019 Computers practical file

    10/50

    or(i";i

  • 8/10/2019 Computers practical file

    11/50

    (ro"ram ase$ on rra of

    Structure ->

    #include#include#include+truct student{ char nameH'",section; int rollno,semester,a/e;*;void main(){ clrscr(); const int n'; student /eniusHn; or(int i";i

  • 8/10/2019 Computers practical file

    12/50

    /etch();*

    (ro"ram ase$ on 'este$

    Structure ->

    #include#include#include

    +truct data{ char nameH'A,section;*ns;+truct student{ int rollno,semester,a/e; data ns;*;void main(){

    clrscr(); student /enius; cout

  • 8/10/2019 Computers practical file

    13/50

    (ro"ram to con#ert numer

    from one sstem to anotheran$ #ice-#ersa ->

    #include#include#includeOoid bdunc();Ooid bounc();Ooid main(){ clrscr(); int I; cout

  • 8/10/2019 Computers practical file

    14/50

    ssa(o-(',i)); ii!; bb!"; * @out

  • 8/10/2019 Computers practical file

    15/50

    bb!"""; * cout

  • 8/10/2019 Computers practical file

    16/50

    (ro"ram ase$ on -* arra

    ->

    #include#include#include#include#[email protected] arra0{ int n,arH!"; Qublic8 void creation(int);

    void traversal(); void insertion(int,int);

    void deletion(int);void bsort(); void bsearch();

    void lsearch(); void mer/in/(int);*;void arra088creation(int no){ int I;

    i(no>!"){

    cout

  • 8/10/2019 Computers practical file

    17/50

    *void arra088traversal(){

    clrscr();int I;

    or(i";i

  • 8/10/2019 Computers practical file

    18/50

    or(x";xend){

    os!;

    cout

  • 8/10/2019 Computers practical file

    19/50

    *void arra088lsearch(){

    int i,os,num;int fa/";

    cout>num;or(i";i;cin>>bn;cout

  • 8/10/2019 Computers practical file

    20/50

    MH0MH0!;MH0!tem;

    **

    *

    *or(a",b",c";a

  • 8/10/2019 Computers practical file

    21/50

    x;/otox0('",x);cout2n; cin>>no; obj.creation(no);*breaP;

    @ase '8 { obj.traversal(); /etch();*breaP();

    @ase =8 { cout>num>>os; obj.insertion(num,os);*breaP;

    @ase 8 { coutos;

    obj.deletion(os); *breaP;

    @ase A8 { obj.bsort(); *breaP;

    @ase F8 { obj.bsearch(); *breaP;

    '!

  • 8/10/2019 Computers practical file

    22/50

    @ase C8 { obj.lsearch(); *breaP;

    @ase K8 { obj.mer/in/(no); *breaP;

    *

    i(ot

  • 8/10/2019 Computers practical file

    23/50

    cin>>aHiHj;*

    *cout

  • 8/10/2019 Computers practical file

    24/50

    sumJaHiHj;*

    **cout

  • 8/10/2019 Computers practical file

    25/50

    *cout

    #include#include#[email protected] stacP{

    Int JHF; int to; ublic8 stacP() {

    to !; * void ush(); void o();

    int isemt0(); void disla0();*;void stacP88ush(){

    i(toF) { cout

  • 8/10/2019 Computers practical file

    26/50

    cin>>JHto; **void stacP88o(){

    cout

  • 8/10/2019 Computers practical file

    27/50

    (ro"ram ase$ on

    im%lementin" 0,1 o%erationsusin" 0'3* 0ST ->

    #include#include

    #include+truct node{

    int data; nodetr;*;void ush(node&to){

    nodet; tne- node;

    coutt >data; tot;*void o(node&to){

    cout

  • 8/10/2019 Computers practical file

    28/50

    {i(to%VSS)

    return !; else return ";

    *void disla0(nodeto){

    nodet; tto; -hile(t5%VSS) {

    cout

  • 8/10/2019 Computers practical file

    29/50

    (ro"ram ase$ on

    im%lementin" ,0,1o%erations usin" &&:

    #include#include#includevoid insertion(intLH,int&,int&r,int num){

    i("&&rC) { cout

  • 8/10/2019 Computers practical file

    30/50

    Int isemt0(int){ i(!)

    Geturn!;else

    return ";

    *;void disla0(int LH,int ,int r){ or(int i;i

  • 8/10/2019 Computers practical file

    31/50

    (ro"ram ase$ on

    im%lementin" ,0,1o%erations usin" 0'3* 0ST

    ->#include#include#includestruct node{ int num;

    nodetr;*;

    void insertion(node&,node&r, int num){

    nodet;tne- node;t>numnum;t>tr%VSS;i(%VSS)

    rt;else

    { r>trt;rt;

    **void deletion(node&,node&r)

    {nodet;

    =!

  • 8/10/2019 Computers practical file

    32/50

    @out

  • 8/10/2019 Computers practical file

    33/50

    (ro"ram ase$ on

    im%lementin" ,0,1o%erations usin" && as

    C0&C5& 655 ->#include#include#include#includevoid insertion (int LH,int&,int&r){

    i(("&&rC)99(r!))@out

  • 8/10/2019 Computers practical file

    34/50

    i(r)r!;

    else!;

    *

    int isemt0(int ){i(!)

    return !;else

    return ";*void disla0(int LH,int ,int r){ int i;

    i(

  • 8/10/2019 Computers practical file

    35/50

    (ro"ram ase$ on &ea$in" 1f

    TXT $ata 7le character

    character ->#include#include#includevoiducaseZalhabets(){

    istream a1le;a1le.oen(4QJGJ.txt);char ch;

    int c";-hile(a1le){ a1le./et(ch); i(isdi/it(ch)) { c;

    **cout

  • 8/10/2019 Computers practical file

    36/50

    clrscr();VcaseZalhabets();/etch();

    *

    (ro"ram ase$ on rea$in" of

    TXT $ata 7le wor$ wor$->

    #include#include#include#includevoid countZ-ord(){

    stream t1le(4+:EGR.txt,ios88in);char str;int c";clrscr();

    -hile(t1le){

    t1le./et(str);i(strD [){

    t1le./et(str)i(tolo-er(str)DtD){

    t1le./et(str);i(islo-er(str)DhD){

    t1le./et(str);i(tolo-er(str)DeD)

    =F

  • 8/10/2019 Computers practical file

    37/50

    {t1le./et(str);

    **i(strD [)

    {c;

    **

    **t1le.close();cout

  • 8/10/2019 Computers practical file

    38/50

    clrscr();countline();/etch();

    *

    (ro"ram ase$ on rea$in" of

    inar $ata 7le for %articularrecor$->

    #include#include#include#include #include#include

    @lass 3SI\W: { int 3no;

    char 3romH'";char :oH'";ublic8

    char \et3rom() {return 3rom;* char \et:o() {return :o;* void $nter() {cin>>3no;/ets(3rom);/ets(:o);* void 7isla0() {cout

  • 8/10/2019 Computers practical file

    39/50

    3SI\W: 3; stream 1n; 1n.oen(43SI\W:.7J:, ios88a9ios88out9ios88binar0); int n, I; clrscr();

    cout n; or(i"; i

  • 8/10/2019 Computers practical file

    40/50

    (ro"ram ase$ on a%%en$in"of inar $ata 7le for nrecor$s->

    #include#include#include#invclude

    #include+truct telrec{ char nameH'"; int tno;* tele;void aend(){ Estream 1le; t1le.oen(4tele.dat , ios88a); int n,I; cout

  • 8/10/2019 Computers practical file

    41/50

    cin

  • 8/10/2019 Computers practical file

    42/50

    (ro"ram ase$ on *eletion in

    inar $ata 7le ->

    #include#include#include#include

    #[email protected] stu{

    int rollno;char nameH'A;char classH;foat marPs;char /rade;ublic8void/etdata(){

    coutrollno;cout

  • 8/10/2019 Computers practical file

    43/50

    cin>>name;coutclass;coutmarPs;

    i(marPs>CA)/radeDJD;else i(marPs>F")

    /radeDMD;else i(marPs>A")

    /rade [@D;else i(marPs>")

    /radeD7D;else /radeD3D;

    *voidutdata(){

    cout

  • 8/10/2019 Computers practical file

    44/50

    1o.close();1le.close();remove(4stu.dat);rename(4tem.dat,stu.dat);1o.oen(4stu.dat,ios88in);

    cout

    :able8 "[email protected]$J:$ :JMS$ Qersonal(

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.