BCA Sem I 2010 Journal

download BCA Sem I 2010 Journal

of 26

Transcript of BCA Sem I 2010 Journal

  • 8/7/2019 BCA Sem I 2010 Journal

    1/26

    Bharati Vidyapeeth Deemed University

    Institute of Management,

    Kolhapur

    JJ

    OO

    UU

    RR

    NN

    AA

    LL

    IT Lab- I ( C, Word, Excel )

    Submitted by: -Mr./MS._______________________

    BCA-I (Semester I)

  • 8/7/2019 BCA Sem I 2010 Journal

    2/26

    Bharati Vidyapeeth Deemed University

    Institute of Management,

    Kolhapur

    Certificate

    Exam Seat No ___________

    This is to certify that Mr./Ms._________________________ of

    BCAI has satisfactorily completed the Practical Assignments

    on IT Lab- I ( C, Word, Excel) for the academic year 2010-

    2011.

    Place: - Kolhapur.

    Date:-

    Prof. P. G. Tandale Prof. A. T. Gaikwad

    H.O.D

  • 8/7/2019 BCA Sem I 2010 Journal

    3/26

    CCOONNTTEENNTT

    Sr.No

    Program Title PageNo

    Sign

    1 First C Program- Hello World

    2 Addition of Two Numbers

    3 Simple Interest Calculation

    4 Temperature Conversion

    5 Printing the pattern of asterisks(*)

    6 Finding reverse of a number

    7 Finding sum of 3-digit number

    8 Fibonacci Series

    9 Roots of Quadratic Equation

    10Finding sum of first n terms of series

    1+3+5++n terms

    11 Greatest among three numbers using ifelse

    12

    Finding average of N numbers

    (use #define & while loop)

    13Printing even numbers from 1 to 100

    (use for loop)

    14 Salesmans salary (use symbolic constants)

    15 Swapping of three numbers

    16 Grading of a student using switch . case

  • 8/7/2019 BCA Sem I 2010 Journal

    4/26

    Sr.

    NoProgram Title

    Page

    NoSign

    17 Number Triangle using for loop

    18 Factorial of a number using recursive function

    19Swapping of two variable using call byreference

    20Sum of squares of 1

    st10 natural numbers

    using array

    21 Different operations of strings

    22 Accessing a variable through its pointer

  • 8/7/2019 BCA Sem I 2010 Journal

    5/26

    Program No. 1- Write a program to print Hello world on screen

    #include

    #include

    int main()

    {

    clrscr( );

    printf("Hello, world\n");

    getch( );

    return 0;

    }

    Output-

    Hello, world

  • 8/7/2019 BCA Sem I 2010 Journal

    6/26

    Program No. 2- Write a program for addition of two numbers

    #include

    #include

    void main(void)

    {

    int number; //varible decleration

    float amount;

    clrscr();

    number=100;

    amount=30.75+75.35;

    printf("%d\n",number); //output

    printf("%5.2f",amount);

    }

    Output-

    100

    106.10

  • 8/7/2019 BCA Sem I 2010 Journal

    7/26

    Program No. 3- Write a program for calculation of Simple Interest.

    #include

    #include

    void main(void)

    {

    int P,N; //varible decleration

    float R,SI;

    clrscr();

    printf("\n Enter Principal Amount, Years & Rate of Interest\n");

    scanf("%d%d%f",&P,&N,&R);

    SI=(P*N*R)/100;

    printf("\nSimple Interest= Rs. %.2f",SI); //output

    getch();

    }

    Output-

    Enter Principal Amount, Years & Rate of Interest

    4000

    5

    5.5

    Simple Interest= Rs. 1100.00

  • 8/7/2019 BCA Sem I 2010 Journal

    8/26

    Program No. 4- Relation between Celsius and Fahrenheit is governed by the

    formula

    325

    9+=

    CF

    Write a program to convert the temperature form Fahrenheit to Celsius.

    #include

    #include

    void main(void){

    float cel,fah;

    clrscr();

    printf("\n Enter the Temperature in Fahrenheit");

    scanf("%f", &fah);

    cel=(fah-32)/1.8;

    printf("\n\n%.2f Fahrenheit= %.2f Degree Celsius" ,fah, cel);

    getch();

    }

    Output-

    Enter the Temperature in Fahrenheit105

    105.00 Fahrenheit= 40.56 Degree Celsius

  • 8/7/2019 BCA Sem I 2010 Journal

    9/26

    Program No. 5- Write a program to print the pattern of asterisks ( * )

    #include

    #include

    void main(void)

    {

    int a,b;

    clrscr();

    printf("\n\n");

    for(a=1;a

  • 8/7/2019 BCA Sem I 2010 Journal

    10/26

    Program No. 6- Write a program for finding reverse of a number.

    #include

    #include

    void main()

    {

    int n,rem,quo,sum;

    rem=0;

    sum=0;

    clrscr();

    printf("\n\n Enter a number: ");

    scanf("%d",&n);

    while(n>0)

    {

    rem=n%10;

    quo=n/10;

    sum=sum*10;

    sum=sum+rem;

    n=quo;

    }

    printf("\n\nReverse of no = %d",sum);

    getch();

    }

    Output-

    Enter a number: 2356

    Reverse of no= 6532

  • 8/7/2019 BCA Sem I 2010 Journal

    11/26

    Program No. 7- Write a program for finding sum of a 3-digit number.

    #include

    #include

    void main()

    {

    int n,s,q,r;

    s=0;

    clrscr();

    printf("\n\nEnter the number:");

    scanf("%d",&n);

    while(n>0)

    {

    r=n%10;

    s=s+r;

    q=n/10;

    n=q;

    }

    printf("Sum of given number is:%d",s);

    getch();

    }

    Output-

    Enter the number:1478

    Sum of given number is:20

  • 8/7/2019 BCA Sem I 2010 Journal

    12/26

    Program No. 8- Write a program to generate Fibonacci series.

    0, 1, 1, 2, 3, 5, 8, 13, 21

    #include

    #include

    void main()

    {

    int n,a,b,i,c;

    a=0;

    b=1;

    i=2;

    clrscr();printf("\n Enter Value of N ");

    scanf("%d",&n);

    printf("\n%d\t%d",a,b);

    do

    {

    i=i+1;

    c=a+b;

    printf("\t%d",c);

    a=b;

    b=c;

    }

    while(i

  • 8/7/2019 BCA Sem I 2010 Journal

    13/26

    Program No. 9- Write a program to find roots of the Quadratic equation

    02 =++ cbxax A quadratic equation has two roots which are given by the formula:

    a

    acbbx

    2

    42 =

    #include

    #include

    #include

    void main()

    {

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

    clrscr();

    printf("\n\nInput value of a,b and c \n");

    scanf("%f%f%f",&a,&b,&c);

    dis=(b*b)-(4*a*c);

    if (dis

  • 8/7/2019 BCA Sem I 2010 Journal

    14/26

    Program No. 10- Write a program for finding sum of first n terns of series

    1 + 3 + 5 + .. + n terms

    #include

    #include

    void main()

    {

    int a,b,sum;

    sum=0;

    clrscr();

    printf("\n\nEnter any numbers:\n");scanf("%d",&b);

    for(a=1; a

  • 8/7/2019 BCA Sem I 2010 Journal

    15/26

    Program No. 11- Write a program to find greatest among three numbers using

    if .. else

    #include

    #includevoid main()

    {

    int a,b,c;

    clrscr();

    printf("\n\nEnter three numbers:\n");

    scanf("%d%d%d",&a,&b,&c);

    if(a>b)

    {

    if(a>c)

    {printf("A is maximum");

    }

    else

    {

    printf("C is maximum");

    }

    }

    else

    {

    if(b>c)

    {

    printf("B is maximum");

    }

    else

    {

    printf("C is maximum");

    }

    }

    getch();

    }

    Output-

    Enter three numbers:

    14

    20

    69

    C is maximum

  • 8/7/2019 BCA Sem I 2010 Journal

    16/26

    Program No. 12- Write a program for finding average of N numbers

    (use #define & while loop)

    #include

    #include

    #define N 10void main()

    {

    int count;

    float sum, average, number;

    sum=0;

    count=0;

    clrscr();

    printf("\n\n\nEnter any 10 numbers\n\n");

    while (count

  • 8/7/2019 BCA Sem I 2010 Journal

    17/26

    Program No. 13- Write a program to print all even numbers from 1 to 100.

    (use for loop)

    #include

    #include

    void main()

    {

    int i,n;

    clrscr();

    printf("\n Enter value of n");

    scanf("%d",&n);

    for(i=1;i

  • 8/7/2019 BCA Sem I 2010 Journal

    18/26

    Program No. 14

    A computer manufacturing company has following monthly compensation policy to

    their sales-persons:

    Minimum basic salary : 1500.00Bonus for every computer sold : 200.00

    Commission on the total monthly sales : 2 %

    Since the prices of computers are changing, the sales price of each computer is fixed

    at the beginning of every month.

    Write a program to computer sales-persons gross salary.

    #include

    #include

    #define BASE_SALARY 1500.00

    #define BONUS_RATE 200.00#define COMMISSION 0.02

    void main()

    {

    int quantity;

    float gross_salary,price;

    float commission,bonus;

    clrscr();

    printf("Input number sold and price\n");

    scanf ("%d %f",&quantity,&price);

    bonus=BONUS_RATE*quantity;

    commission=COMMISSION*quantity*price;

    gross_salary=BASE_SALARY+bonus+commission;

    printf("\n Bonus= %6.2f",bonus);

    printf("\n Commission= %6.2f",commission);

    printf("\n Gross Salary= %6.2f",gross_salary);

    getch();

    }

    Output-

    Input number sold and price

    6 14500.00

    Bonus= 1200.00

    Commission= 1740.00

    Gross Salary= 4440.00

  • 8/7/2019 BCA Sem I 2010 Journal

    19/26

    Program No. 15- Write a program for swapping of three numbers.

    AB C

    #include

    #include

    void main()

    {

    int a,b,c,temp;

    clrscr();

    printf("\n Enter any two number:");

    scanf("%d%d%d",&a,&b,&c);

    temp=a;

    a=b;

    b=c;

    c=temp;

    printf("\nSwapped numbers are %d %d %d",a,b,c);

    getch();

    }

    Output-

    Enter any two number:25 36 42

    Swapped numbers are 36 42 25

  • 8/7/2019 BCA Sem I 2010 Journal

    20/26

    Program No. 16- Write a program to find grade obtained by the student in exam.

    ( use switch . case)

    #include

    #include

    void main()

    {

    int marks,index;

    char grade;

    clrscr();

    printf("\n\nEnter marks obtained: ");

    scanf("%d",&marks);

    index=marks/10;

    switch(index)

    {case 10:

    case 9:

    case 8:

    case 7:

    grade='D';

    break;

    case 6:

    grade='1';

    break;

    case 5:

    grade='2';

    break;

    case 4:

    grade='P';

    break;

    default:

    grade='F';

    break;

    }

    printf("\n Grade obtained is %c", grade);getch();

    }

    Output-

    Enter marks obtained: 67

    Grade obtained is 1

  • 8/7/2019 BCA Sem I 2010 Journal

    21/26

    Program No. 17- Write a program to generate number triangle using for loop

    #include

    #include

    void main(void)

    {

    int a,b;

    clrscr();

    printf("\n\n");

    for(a=1;a

  • 8/7/2019 BCA Sem I 2010 Journal

    22/26

    Program No. 18- Write a program to find factorial of a number using recursive

    function.

    N factorial = N! =1*2*3*4*..*N

    #include#include

    int fact(int);

    void main()

    {

    int n,a,f;

    clrscr();

    printf("\n\nEnter the number:");

    scanf("%d",&n);

    a=fact(n);printf("\n\nFactorial=%d",a);

    getch();

    }

    int fact(int n)

    {

    int m;

    if(n==1 || n==0)

    return(1);

    else

    {

    m=n*fact(n-1);

    return(m);

    }

    }

    Output-

    Enter the number:6

    Factorial=720

  • 8/7/2019 BCA Sem I 2010 Journal

    23/26

    Program No. 19- Write a program for swapping of two variables using call by

    reference

    #include

    #include

    void exchange(int*p,int*q);

    void main()

    {

    int x,y;

    clrscr();

    x=29;

    y=7;

    printf("\nValues before exchange x=%d,y=%d",x,y);

    exchange(&x,&y);

    printf("\nValues after exchange x=%d,y=%d",x,y);getch();

    }

    void exchange(int*p,int*q)

    {

    int temp;

    temp=*p;

    *p=*q;

    *q=temp;

    }

    Output-

    Values before exchange x=29,y=7

    Values after exchange x=7,y=29

  • 8/7/2019 BCA Sem I 2010 Journal

    24/26

    Program No. 20- Write a program to find average of 10 numbers using array.

    #include

    #include

    void main(){

    int i;

    int x[10],value,total;

    clrscr();

    printf("\n\nEnter 10 numbers:\n");

    for(i=0;i

  • 8/7/2019 BCA Sem I 2010 Journal

    25/26

    Program No. 21- Write a program to illustrate different operations on string.

    #include

    #include

    #include

    void main()

    {

    char s1[20],s2[20],s3[20];

    int x,l1,l2,l3;

    clrscr();

    printf("\n\nEnter two string constants");

    scanf("%s %s",s1,s2);

    x=strcmp(s1,s2); //comparing

    if(x!=0)

    {

    printf("\n Strings are not equal");strcat(s1,s2); // joining s1 and s2

    }

    else

    printf("\n Stings are equal");

    strcpy(s3,s1); //copying s1 to s3

    // finding length of string

    l1=strlen(s1);

    l2=strlen(s2);

    l3=strlen(s3);

    printf("\ns1=%s\t length = %d characters",s1,l1); //output

    printf("\ns2=%s\t length = %d characters",s2,l2);

    printf("\ns3=%s\t length = %d characters",s3,l3);

    getch();

    }

    Output-

    Enter two string constants

    Kolhapur

    Sangli

    Strings are not equal

    s1=KolhapurSangli length = 14 characters

    s2=Sangli length = 6 characters

    s3=KolhapurSangli length = 14 characters

  • 8/7/2019 BCA Sem I 2010 Journal

    26/26

    Program No. 22- Write a program to access a variable though its pointer.

    #include

    #include

    void main(void)

    {

    int x,y;

    int *ptr;

    clrscr();

    x=10;

    ptr=&x;

    y=*ptr;printf("Value of x is %d\n\n",x);

    printf("%d is stored at addr %u\n", x,&x);

    printf("%d is stored at addr %u\n", *&x,&x);

    printf("%d is stored at addr %u\n", *ptr,ptr);

    printf("%d is stored at addr %u\n", ptr,&ptr);

    printf("%d is stored at addr %u\n", y,&y);

    *ptr=25;

    printf("\n Now x= %d\n",x);

    getch();

    }

    Output-

    Value of x is 10

    10 is stored at addr 65524

    10 is stored at addr 65524

    10 is stored at addr 65524

    -12 is stored at addr 65520

    10 is stored at addr 65522

    Now x= 25