Cs Project Work

Embed Size (px)

Citation preview

  • 8/12/2019 Cs Project Work

    1/39

  • 8/12/2019 Cs Project Work

    2/39

    2

    Index

    S.no. Topic Pageno. Grade Sign.01.

    Program to print your name,class and roll no. on the screen. 4-4

    02.Program that inputs a students

    marks in three subjects (out of 100)and prints the percentage marks. 4-5

    03.Program that accepts radius

    of a circle and print its area. 5-6

    04.Program (using a function) to accept

    a number and print its cube. 6-7

    05.Program that accepts a characterbetween a to j and prints next 4

    characters. 7-8

    06.Program to chain multiple

    assignments (as many as possible). 8-9

    07.The value of e is known to be 2.71828...

    Using this value, write a program todetermine the value of this expression:

    2-ye 2y+4y. Obtain value of y from the user. 9-10

    08.Program that reads in a character from

    the keyboard and then displays one of thefollowing messages:

    (i) if is a lower case letter, the messagethe upper case character corresponding to

    is, (ii) if is an uppercase letter, the message

    The lower case character corresponding to is,

    (iii)if is not a letter, the message isno t a letter.

    10-12

    09.Temperature-conversion program thatgives the user the option for converting

    Fahrenheit to Celsius or Celsius toFahrenheit and depending upon users

    choice carries out the conversion.

    12-13

  • 8/12/2019 Cs Project Work

    3/39

    3

    10.Program to accept three integersand print the largest of the three.

    Making use of if statement. 14-15

    11.

    Program to create the equivalent of four-function calculator. The program requires

    the user to enter two numbers and anoperator. It then carries out the specified

    arithmetical operation: addition,subtraction, multiplication or division ofthe two numbers. Finally, it displays the

    result.

    15-16

    12.Program to calculate commission for

    salesmen. The commission iscalculated according to given rates. 17-19

    13.Program to calculate and printroots of a quadratic equation

    ax2

    +bx+c. 19-21

    14. Program to calculate thefactorial of an integer. 21-22

    15.Program to show handicap

    of call by value method. 22-24

    16. Program to swap twovalues. 24-26

    17. Program to add twomatrices. 26-29 18.

    Program to illustrate passingof structure by value. 29-31

    19.Program to illustrate passing

    of structure by reference. 31-34

    20.Program to find row sum

    and column sum of matrix. 34-36

    21. Program to multiply twomatrices. 36-39

  • 8/12/2019 Cs Project Work

    4/39

    4

    Program-1: Program to print your name, class and rollno. on the screen.

    #include#include //for clear screen function clrscr()

    Int main()

    {

    Clrscr();

    Cout

  • 8/12/2019 Cs Project Work

    5/39

    5

    System (cls);

    float sub1,sub2,sub3,marks,perc;

    coutsub1>>sub2>>sub3;

    Marks=sub1+sub2+sub3;

    Perc=(marks/300)*100;

    Cout

  • 8/12/2019 Cs Project Work

    6/39

  • 8/12/2019 Cs Project Work

    7/39

    7

    cin>>num;

    cout

  • 8/12/2019 Cs Project Work

    8/39

    8

    Ch2=ch+2

    Ch3=ch+3;

    Ch4=ch+4;

    cout

  • 8/12/2019 Cs Project Work

    9/39

    9

    Int r2,s2,t2,u2,v2,w2,x2,y2,z2;

    a=b=c=d=e=f=g=h=i=j=k=l=m=n=0

    =p=q=r=s=t=u=v=w=x=y=z

    =a1=b1=c1=d1=e1=f1=g1=h1=i1=j1=k1=l1=m1=n1=o1=p1=q1

    =r1=s1=t1=u1=v1=w1=x1=y1=z1=a2=b2=c2=d2=e2=f2=g2=h2

    =i2=j2=k2=l2=m2=n2=o2=p2=q2=r2=10;

    cout

  • 8/12/2019 Cs Project Work

    10/39

    10

    {

    const double e=2.71828;

    double result,y;

    couty;

    result=2-y*exp(2*y)+pow(4,y);

    cout

  • 8/12/2019 Cs Project Work

    11/39

  • 8/12/2019 Cs Project Work

    12/39

  • 8/12/2019 Cs Project Work

    13/39

    13

    coutchoice;

    If(choice==1)

    {

    cout

  • 8/12/2019 Cs Project Work

    14/39

    14

    Program 10: Program to accept three integers and print

    the largest of the three. Making use of if statement.#include

    Int main()

    {

    Int x,y,z,max;

    coutx>>y>>z;

    max=x;

    If(y>max)

    max=y;

    If(z>max)

    max=z;

    cout

  • 8/12/2019 Cs Project Work

    15/39

    15

    Enter three numbers : 3 5 6

    The largest of 3, 5 and 6 is 6

    Program 11: Program to create the equivalent of four-function calculator. The program requires the user toenter two numbers and an operator. It then carries outthe specified arithmetical operation: addition,

    subtraction, multiplication or division of the twonumbers. Finally, it displays the result.

    #include

    Int main()

    {

    char ch;

    float a,b,result;

    couta>>b;

    coutch;

    cout

  • 8/12/2019 Cs Project Work

    16/39

    16

    If(ch== )

    result=a+b;

    else

    If(ch==-)

    result=a-b;

    else

    If(ch== )

    result=a*b;

    else

    If(ch==/)

    result=a/b;

    else

    cout

  • 8/12/2019 Cs Project Work

    17/39

    17

    Program 12: Program to calculate commission forsalesmen. The commission is calculated according to

    given rates.

    Sales Commission Rate3001 onwards 15%22001-30000 10%12001-22000 7%5001-12000 3%

    0-5000 0%#include

    Int main()

    {

    float sales,comm;

    coutsales;

    If(sales>5000)

    If(sales>12000)

    If(sales>22000)

    If(sales>30000)

    comm=sales*0.15;

  • 8/12/2019 Cs Project Work

    18/39

    18

    else

    comm=sales*0.10;

    else

    comm=sales*0.07;

    else

    comm=sales*0.03;

    else

    comm=0;

    cout

  • 8/12/2019 Cs Project Work

    19/39

    19

    The commission is:4950

    Program 13: Program to calculate and print roots of aquadratic equation ax 2+bx+c.

    #include

    #include

    Int main(){

    float a,b,c,root1,root2,delta;

    coutb>>c;

    If(!a)

    cout

  • 8/12/2019 Cs Project Work

    20/39

  • 8/12/2019 Cs Project Work

    21/39

    21

    return 0;

    }

    Output-

    Enter three numbers a,b&c of ax^2+bx+c:

    2 3 4

    Roots are complex and imaginary

    Program 14: Program to calculate the factorial of aninteger.

    #include

    #include

    Int main()

    {

    System(cls);

    Int I,num,fact=1;

    coutnum;

    I=num;

  • 8/12/2019 Cs Project Work

    22/39

  • 8/12/2019 Cs Project Work

    23/39

  • 8/12/2019 Cs Project Work

    24/39

    24

    }

    Output-

    Original values are:

    a=7, b=4

    Swapped values are: a=4, b=7

    The values after swap() are:

    a=7, b=4

    Program 16: Program to swap two values.

    #include

    Int main()

    {

    void swap(int,int);

    Int a,b;

    a=7;

    b=4;

    cout

  • 8/12/2019 Cs Project Work

    25/39

    25

    cout

  • 8/12/2019 Cs Project Work

    26/39

  • 8/12/2019 Cs Project Work

    27/39

    27

    If((m==p)&&(n==q))

    cout

  • 8/12/2019 Cs Project Work

    28/39

    28

    cout

  • 8/12/2019 Cs Project Work

    29/39

    29

    for(j=0;j

  • 8/12/2019 Cs Project Work

    30/39

    30

    cout

  • 8/12/2019 Cs Project Work

    31/39

    31

    cout

  • 8/12/2019 Cs Project Work

    32/39

  • 8/12/2019 Cs Project Work

    33/39

  • 8/12/2019 Cs Project Work

    34/39

  • 8/12/2019 Cs Project Work

    35/39

    35

    cout

  • 8/12/2019 Cs Project Work

    36/39

    36

    }

    for(i=0;i

  • 8/12/2019 Cs Project Work

    37/39

    37

    If(n==p)

    {

    cout

  • 8/12/2019 Cs Project Work

    38/39

    38

    for(i=0;i

  • 8/12/2019 Cs Project Work

    39/39

    }

    else

    cout