cs programs

Upload: satyag24

Post on 03-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Cs Programs

    1/26

    Computer Science Practical File

    Submitted by:

    G Satya, XII-B

  • 8/12/2019 Cs Programs

    2/26

    ntentsPr gram t :

    1. Print sum o ! prime no.s2. Sum o series 1"#$%$"#&%&"#'%'"(((upto ! terms$. Print ! terms o Fibonacci series). Count no. o *o+els, consonants and digits in a string&. Cec +eter a string is a palindrome. Sort an array +it selection sort'. Sort an array +it bubble sort/. Sort an array +it insertion sort0. Searc an array using inear searc

    12. Searc an array using Binary searc11. 3elete an item at tocation o an array

    14. Insert an item at tocation o an array1$.Concat t+o arrays1).5dd t+o 6atrices o $#)1&.Product o t+o 6atrices 74#$ and $#48

  • 8/12/2019 Cs Programs

    3/26

    1. //program to print the sum of n prime nos.#include#includevoid main(){

    clrscr();

    int *p,chk!,n,s!,div,i;//*p for storing n prime nos.//chk is to check if no. is primecoutn;do{if(n

  • 8/12/2019 Cs Programs

    4/26

    'cout

  • 8/12/2019 Cs Programs

    5/26

    . //a program to calc the sum of series 1/-2+1(cu%e)/32+....to n terms#include#include#includevoid main(){

    clrscr();long fact-;int n,1;float sum!;cout1;coutn;for(int i-;i

  • 8/12/2019 Cs Programs

    6/26

    3. //print n terms of fi%onacci series

    #include#includevoid main(){ clrscr(); int n,*s; coutn; s!!; s--; cout

  • 8/12/2019 Cs Programs

    7/26

    9.//60 :056 0=?@, :0@06@ AB 5CDE@........#include#include#include#include

    void main(){ clrscr(); char a-; int vcnt!,ccnt!,ncnt!; cout

  • 8/12/2019 Cs Programs

    8/26

    I.//to find if a given string is paindrome or not.....#include#include#include#includevoid main()

    { clrscr();char aI-;int check!;cout

  • 8/12/2019 Cs Programs

    9/26

    K.//selection sort#include#includefloat @?L@0E6(float *A,int ){ for(int i!;i

  • 8/12/2019 Cs Programs

    10/26

    M.//%u%%le sort#include#includefloat D5DD?L@0E6(float *A,int ){ for(int i!;i

  • 8/12/2019 Cs Programs

    11/26

    N.//Insertion Sort

    #include

    #include

    #include

    void main()

    { clrscr();

    int a[100!i!n!"!"tr!tem";

    cout

  • 8/12/2019 Cs Programs

    12/26

    O./* program to accept an arra containing float tpe elements and search an element H6C in the arra ith the help of linear search % using the function ?HAEL@AE:P()*/#include#include

    void ?HAEL@AE:P(float *A,int ,float H6C){ int *pos,4!; pos!8OO;//8ve value for for(int i!;i>; cout

  • 8/12/2019 Cs Programs

    13/26

    -!.//Dinar search#include#includeint DHAEJL@AE:P(int A, int , int A?){

    int Cid,?%ound!,5%ound8-;

    hile(?%oundACid)

    ?%oundCid+-;else if(A?

  • 8/12/2019 Cs Programs

    14/26

    0utput$

  • 8/12/2019 Cs Programs

    15/26

    --./* program to accept arra A of float elements.function to delete an item from the arra atkth location*/#include#include#include

    void B?6LH6C(float *A,int R,float item){

    int p,chk!;for(int i!;i

  • 8/12/2019 Cs Programs

    16/26

    B?6LH6C(A,,item);cout

  • 8/12/2019 Cs Programs

    17/26

    -./* program to accept arra A of float elements.function to insert an item in the arra at kth location */#include#include#include//- e1tra free space is needed in the memor for its correct orking

    void H@E6LH6C(float *A,float item,int R,int S){

    if(S){ cout

  • 8/12/2019 Cs Programs

    18/26

    'hile(k

  • 8/12/2019 Cs Programs

    19/26

    -3/* program to accept ARD containing RC elements respectivel and concat ARD and store the result in the third arra : % using a function :0:A6()*/#include#includeint *:0:A6(int *A,int*D,int C,int )

    {int *:;for(int i!;i

  • 8/12/2019 Cs Programs

    20/26

    cout

  • 8/12/2019 Cs Programs

    21/26

  • 8/12/2019 Cs Programs

    22/26

    c; ' c; r-!;cout

  • 8/12/2019 Cs Programs

    23/26

    0utput$

  • 8/12/2019 Cs Programs

    24/26

    -I./* a program to accept to matrices A and D of 13 and 31 order respective,calculate their product using functon 7E0CA6() and displa A, D and 7E0B5:6*/#include#include//structure to store a matri1 of -! T -! order

    struct CA6EHT{ int Cat-!-!;';/* function to multipl to matri1 A of m T n order and matri1 D of p T U order*/CA6EHT 7E0CA6(int A-!,int m,int n,int D-!,int U){

    //assuming nd order of matrices i.e. columns as ma1. -!CA6EHT :; //to store product of A and D

    for(int i!;i

  • 8/12/2019 Cs Programs

    25/26

    c; r-!;cout

  • 8/12/2019 Cs Programs

    26/26