Programs

 Practical No: 1.

1. Write a program in C to input the two numbers and find the

 Addition, Substraction, Multiplication and Division in one file.

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 int x, y, sum, sub, multi;

 float div;

 clrscr ( );

 printf (“enter the first number x=”);

 scanf (“%d”, &x);

 printf (“enter the second number y=”);

 scanf (“%d”, &y);

 sum=x+y;

 sub=x-y;

 multi=x*y;

 div=x/y;

 printf (“\n Addition=%d \n

Substraction=%d\n

Multiplication=%d \n

Division=%f”, sum, sub, multi, div);

 getch ( );

}





Practical No: 2.

1. Write a program in C to input the two numbers and find the Average.


 #include<stdio.h>

 #include<conio.h>


 void main ( )

 {

 int a, b, sum, avg;

 clrscr ( );

 printf (“enter the first number:”);

 scanf (“%d”, &a);

 printf (“enter the second number:”);

 scanf (“%d”, &b);

 sum=a+b;

 avg=sum/2;

 printf (“average %d”, avg);

 getch ( );

 }




Practical No: 2.

2. Write a C program to input three integers and then display Maximum of

 the three numbers.

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 int a, b, c;

 clrscr ( );

 printf (“enter the first no. ”);

 scanf (“%d”, &a);

 printf (“enter the second no. ”);

 scanf (“%d”, &b);

 printf (“enter the third no. ”);

 scanf (“%d”, &c);

 if(a>b)

 printf (“the largest number is =%d”, a);

 else if(b>c)

 printf (“the largest number is =%d”, b);

 else

 printf (“the largest number is =%d”, c);

 getch ( );

 } 





Practical No: 3.

1. Write a program in C to input the Basic pay and calculate and display

 Basic Pay, DA, HRA, Total Pay and Tax where DA as 60% of Basic Pay,

 Total as Basic Pay+DA+HRA and tax as 20% of the Total Pay.

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 float basic, DA, HRA, Tpay, Tax;

 clrscr ( );

 printf (“enter basic pay: ”);

 scanf (“%f”, &basic);

 DA=basic*60/100;

 HRA=basic*25;

 Tpay=basic+DA+HRA;

 Tax=Tpay*20;

 printf (“basic pay=%.2f\n”, basic);

 printf (“DA=%.2f\n”,da);

 printf (“HRA=%.2f\n”,hra);

 printf (“Total pay=%.2f\n”,tpay);

 printf (“Tax=%.2f\n”,tax);

 getch ( );

 }



Practical No: 3.

2. Write a program in C to input the Cost, Salvage value and estimated life

 in years of an asset and display the Annual Depreciation where

 depreciation=(cost-salvage)/life.

 #include<stdio.h>

 #include<conio.h>


 void main ( )

 {

 float cost, salvage, estlife, depreciation;

 clrscr ( );

 printf (“enter the cost: ”);

 scanf (“%f”, &cost);

 printf (“enter the salvage: ”);

 scanf (“%f”, &salvage);

 printf (“enter the estlife: ”);

 scanf (“%f”, &estlife );

 depreciation=(cost-salvage)/estlife;

 printf (“depreciation=%.2f”, depreciation);

 getch ( );

 }



Practical No: 4.

1. To input Telephone No. and Number of Calls made; Calculate and

 display the Bill Amount which include a fixed rate of 250 first 60 calls

 are free & excess calls are charged @ 80paise each.

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 long tn ;

 int n ;

 float b_amt ;

 clrscr ( );

 printf (“enter the telephone no:”);

 scanf (“%ld”, &tn);

 printf (“enter the no. of the made:”);

 scanf (“%d”, &n);

 if (n<=60)

 b_amt=250;

 else

 b_amt=250+(n-60)*80/100;

 printf (“Bill amount %.2f”, b_amt);

 getch ( );

 }


Practical No: 4.

2. Write a program in C to accept Amount and then display the sales

amount, Discount and Net amount where Discount is 5% of sales.

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 float sales, discount, namount;

 clrscr ( );

 printf (“enter the sales :”);

 scanf (“%f”, &sales);

 discount =sales*0.05;

 namount=sales-discount;

 printf (“namount=%.2f”, namount);

 getch ( );

 } 




Practical No: 5.

1. Write a program in C to input 2 numbers & Arithmetic operator and give

 the result of the operator on the 2 numbers using switch ( ).

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 float a, b;

 char k;

 clrscr ( );

 printf (“enter the first nos: ”);

 scanf (“%f”, &a);

 printf (“enter the second nos: ”);

 scanf (“%f”, &b);

 printf (“enter a arithmetic operator: “);

 scanf (“%s”, &k);

 switch(k)

 {

 case ‘+’ :

 printf (“%f\n”,a+b);

 break;

 case ‘-’ :

 printf (“%f\n”,a-b);

 break;

 case ‘*’ :

 case ‘x’ :

 printf (“%f\n”,a*b);

 break;

 case ‘/’ :

 printf (“%f\n”,a/b);

 break;

 default :

 printf (“OPERATOR INCORRECT\n”);

 break;

 }

 getch();

 }


2. Write a program in C to input the Gross Income and calculate Income

 Tax:

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 float gi, itax, ni;

 clrscr ( );

 printf (“enter the gross income :”);

 scanf (“%f” ,&gi);

 if(gi<60000)

 itax=0.00;

 else if(gi<=110000)

itax=0.10*(gi-60000);

else if(gi<=160000)

itax=5000+0.15*(gi-110000);

else

itax=12500+0.20*(gi-160000);

 printf(“gross income: rs%.2f\n”,gi);

 printf(“income tax: rs%.2f\n”,itax);

 printf(“net income: rs%.2f\n”,gi-itax);

 getch ( );

 }



Practical No: 6.

1. Write a program in C to input the Amount Invested (a), the Rate of

 interest(r) and the Period of Investment in Years (n). Calculate and

 display the Simple Interest on the same. {SI= a*r*n/100}

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 float a, r, n, si;

 clrscr ( );

 printf (“Enter the Amount Invested: ”);

 scanf (“%f”, &a);

 printf (“Enter the Rate of Interest: ”);

 scanf (“%f”, &r);

 printf (“Enter the Period of Investment in Years: ”);

 scanf (“%f”, &n);

 si=a*r*n/100;

 printf (“Simple interest =%.2f\n”, si );

 getch ( );

 }

 



Practical No: 6.

2. Write a program in C to input the Marks of a student in 3 subjects and

 calculate Total and Average marks. Display the Result of the student

 along with the Total and Average marks , where the result is “PASS” if the

 student gets 35 or more in each subject , otherwise result is “FAIL”.

 #include<stdio.h>

 #include<conio.h>

 void main ( )

 {

 float m1, m2, m3, tm, avg;

 clrscr ( );

 printf (“Enter the marks in Hindi:\n”);

 scanf (“%f”,m1);

 printf (“Enter the marks in Marathi:\n”);

 scanf (“%f”,m2);

 printf (“Enter the marks in English:\n”);

 scanf (“%f”,m3);

 tm=m1+m2+m3;

 avg=tm/3;

 printf (“total marks=%.2f\n”, tm);

 printf (“average marks=%.2f\n”, avg);

 if (m1>=35 && m2>=35 && m3>=35)

 printf (“pass”);

 else

 printf (“fail”);

 getch ( );

 }




Post a Comment

Previous Post Next Post