0% found this document useful (0 votes)
1K views

DOTE TNDTE C Programming LAB

34036- PROGRAMMING IN “C” PRACTICAL LIST OF EXPERIMENTS DOTE TNDTE c practical c lab C language program to find Resonant Frequency C language program to calculate the equivalent Capacitance C language program to calculate the equivalent resistance C language program to find the power factor C language program to find Resonant Frequency of RLC Series C language program to find the Q factor for series C language program to draw the symbol of NPN transistor using Graphics C language program to draw the symbol of Diode using Graphics dote tndte government polytechnic college TNEB c lab c practical programming in c m scheme ece 34036 c language program quadratic equation While loop Arithmetic operation switch case statement add sub mul div result student mark ohm law ohms law factorial array structure marks total marks swap two variables equivalent resistance series and parallel three resistances equivalent Capacitance three Capacitors Resonant Frequency RLC Series power factor RL circuits resonant circuits Q factor NPN transistor draw the symbol of NPN draw the symbol of Diode Diode using Graphics NPN transistor using Graphics

Uploaded by

smagendiran
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

DOTE TNDTE C Programming LAB

34036- PROGRAMMING IN “C” PRACTICAL LIST OF EXPERIMENTS DOTE TNDTE c practical c lab C language program to find Resonant Frequency C language program to calculate the equivalent Capacitance C language program to calculate the equivalent resistance C language program to find the power factor C language program to find Resonant Frequency of RLC Series C language program to find the Q factor for series C language program to draw the symbol of NPN transistor using Graphics C language program to draw the symbol of Diode using Graphics dote tndte government polytechnic college TNEB c lab c practical programming in c m scheme ece 34036 c language program quadratic equation While loop Arithmetic operation switch case statement add sub mul div result student mark ohm law ohms law factorial array structure marks total marks swap two variables equivalent resistance series and parallel three resistances equivalent Capacitance three Capacitors Resonant Frequency RLC Series power factor RL circuits resonant circuits Q factor NPN transistor draw the symbol of NPN draw the symbol of Diode Diode using Graphics NPN transistor using Graphics

Uploaded by

smagendiran
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

GPT-KRISHNAGIRI-ECE-PART TIME 2017

34036- PROGRAMMING IN C PRACTICAL LIST OF EXPERIMENTS

1. Write C language program to find the solution of a quadratic equation.


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c, discriminant,root1,root2;
clrscr();
printf ("Enter The Input Values at a,b,c \n");
scanf ("%f%f%f", &a, &b, &c);
discriminant =b*b-4*a*c;
if (discriminant <0)
printf ("\n\n ROOTS ARE IMAGINARY");
else
{
root1 =(-b+sqrt(discriminant))/(2.0*a);
root2 =(-b-sqrt(discriminant))/(2.0*a);
printf ("\n\n Root 1= %5.2f \n\n Root 2= %5.2f \n",root1,root2);
printf ("\n\n Press Any Key Continue \n");
}
getch();
}
OUTPUT
Enter The Input Values at a,b,c
2 4 -7
Root 1= 1.12
Root 2= -3.12
Press Any Key Continue
Enter The Input Values at a,b,c
246
ROOTS ARE IMAGINARY

Prepared by tptmagendiranatgmaildotcom

Page 1

GPT-KRISHNAGIRI-ECE-PART TIME 2017

2. Write C language program to find whether the given number is a positive number, negative
number or zero.
#include<stdio.h>
#include<conio.h>
void main()
{
int number;
clrscr();
printf ("Enter the number \n");
scanf ("%d", & number);
if (number >0)
{
printf ("number is positive \n");
}
else if (number <0)
{
printf ("number is nagative \n");
}
else
{
printf ("number is zero \n");
}
getch();
}
OUTPUT
Enter the number
8
number is positive
Enter the number
-8
number is nagative
Enter the number
0
number is zero

Prepared by tptmagendiranatgmaildotcom

Page 2

GPT-KRISHNAGIRI-ECE-PART TIME 2017

3. Write C language program to find the sum of series using While loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i=1, sum=0;
clrscr();
printf ("Enter The Value of \n");
scanf ("%d", & n);
printf ("first % d numbers are \n",n);
while (i<=n)
{
printf ("%d",i);
sum=sum+i;
i++;
}
printf ("\n sum=%d \n",sum);
getch();
}
OUTPUT
Enter The Value of
10
first 10 numbers are
12345678910
sum=55

Prepared by tptmagendiranatgmaildotcom

Page 3

GPT-KRISHNAGIRI-ECE-PART TIME 2017

4. Write C language program to perform the Arithmetic operation based on the numeric key press
using switch case statement. (1-Addition, 2-Subtraction, 3 multiplication, 4 - Division).
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int choice;
float a,b,c;
clrscr();
printf ("Enter The 2 Numbers \n");
scanf ("%f%f",&a,&b);
printf ("\n 1 Add 2 Sub 3 Mul 4 Div \n");
printf ("Enter The Choice \n");
scanf ("%d",& choice);
switch (choice)
{
case 1:
c= a+b;
break;
case 2:
c= a-b;
break;
case 3:
c= a*b;
break;
case 4:
c= a/b;
break;
defalut : printf ("wrong choice !!! \n Press any Key");
}
getch();
printf("\n Result= %f",c);
getch();
}

Prepared by tptmagendiranatgmaildotcom

Page 4

OUTPUT

GPT-KRISHNAGIRI-ECE-PART TIME 2017

Enter The 2 Numbers


22
1 Add 2 Sub 3 Mul 4 Div
Enter The Choice
1
Result= 4.000000
Enter The 2 Numbers
42
1 Add 2 Sub 3 Mul 4 Div
Enter The Choice
2
Result= 2.000000
Enter The 2 Numbers
52
1 Add 2 Sub 3 Mul 4 Div
Enter The Choice
3
Result= 10.000000

Enter The 2 Numbers


82
1 Add 2 Sub 3 Mul 4 Div
Enter The Choice
4
Result= 4.000000

Prepared by tptmagendiranatgmaildotcom

Page 5

GPT-KRISHNAGIRI-ECE-PART TIME 2017

5. Write C language program to implement Ohms Law.


#include<stdio.h>
#include<conio.h>
void main()
{
float v,r,i;
clrscr();
printf ("Enter The Voltage V, Resistance R \n");
scanf ("%f%f", &v, &r);
i=v/r;
printf ("\n The Current is = %f A",i);
getch();
}
OUTPUT
Enter The Voltage V, Resistance R
10 2
The Current is = 5.000000 A

Prepared by tptmagendiranatgmaildotcom

Page 6

GPT-KRISHNAGIRI-ECE-PART TIME 2017

6. Write C language program to find factorial of given N numbers using function.


#include<stdio.h>
#include<conio.h>
void main()
{
int n;
void fact (int);
clrscr();
printf ("Given the value of n \n");
scanf ("%d", &n);
fact (n);
}
void fact (int m)
{
int i,j;
int f=1;
for(i=1;i<=m;i++)
{
for(j=1;j<=m;j++)
{
f=f*j;
}
printf ("\n factorial of %d is %d\t\n",i,f);
f=1;
}
getch();
}
OUTPUT
Given the value of n
4
factorial of 1 is 24
factorial of 2 is 24
factorial of 3 is 24
factorial of 4 is 24

Prepared by tptmagendiranatgmaildotcom

Page 7

GPT-KRISHNAGIRI-ECE-PART TIME 2017

7. Write C language program to prepare the total marks for N students by reading the Name,
Reg.No, Marks 1 to Marks 6 using array of structure.
#include<stdio.h>
#include<conio.h>
struct student
{
int i,j,regno;
char name [20];
int mark [20];
int total;
};
void main ()
{
struct student s[100];
int i,j,n;
clrscr ();
printf ("\n Enter the number of student \n");
scanf ("%d",&n);
for(i=0;i<n;i++)
{
printf ("\n Enter the register number, name and 6 marks one by
one \n");
scanf ("%d%s",&s[i].regno,s[i].name);
for(j=0;j<=5;j++)
{
scanf("%d",&s[i].mark[j]);
}
}
printf("\n*******************************************");
printf("\n GPT KRISHNAGIRI");
printf("\n Number\t Name\t TotalMarks");
printf("\n*******************************************\n");
for(i=0;i<n;i++)
{
s[i].total=0;
for(j=0;j<6;j++)
{
s[i].total=s[i].total+s[i].mark[j];
}
printf("%d\t%s\t%d\n",s[i].regno,s[i].name,s[i].total);
}
getch();
}

Prepared by tptmagendiranatgmaildotcom

Page 8

OUTPUT

GPT-KRISHNAGIRI-ECE-PART TIME 2017

Enter the number of student


2
Enter the register number, name and 6 marks one by one
123
murali
100
90
90
90
80
80

Enter the register number, name and 6 marks one by one


124
madash
100
100
90
90
80
80
*******************************************
GPT KRISHNAGIRI
Number
Name
TotalMarks
*******************************************
123
murali
530
124
madash
540

Prepared by tptmagendiranatgmaildotcom

Page 9

GPT-KRISHNAGIRI-ECE-PART TIME 2017

8. Write C language program to swap the values of two variables.


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b;
clrscr();
printf ("Enter The value for a and b \n");
scanf ("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf ("\n After Swaping Number is a and b is %d it %d \n",a,b);
getch();
}
Output
Enter The value for a and b
57
After Swaping Number is a and b is 7 it 5

Prepared by tptmagendiranatgmaildotcom

Page 10

GPT-KRISHNAGIRI-ECE-PART TIME 2017

9. Write C language program to calculate the equivalent resistance of three resistances connected
in series and parallel.
#include<stdio.h>
#include<conio.h>
void main()
{
float r1,r2,r3,rs,rp;
clrscr();
printf ("Enter The Resistance r1,r2,r3: \n");
scanf ("%f%f%f", &r1,&r2,&r3);
rs=r1+r2+r3;
rp=1/(1/r1+1/r2+1/r3);
printf ("\n Equivalent resistance in series: %f",rs);
printf ("\n Equivalent resistance in parallel: %f",rp);
getch();
}
Output
Enter The Resistance r1,r2,r3:
246
Equivalent resistance in series: 12.000000
Equivalent resistance in parallel: 1.090909
10. Write C language program to calculate the equivalent Capacitance of three Capacitors
connected in series and parallel.
#include<stdio.h>
#include<conio.h>
void main()
{
float c1,c2,c3,cs,cp;
clrscr();
printf ("Enter The Capacitance c1,c2,c3: \n");
scanf ("%f%f%f", &c1,&c2,&c3);
cs=1/(1/c1+1/c2+1/c3);
cp=c1+c2+c3;
printf ("\n Equivalent Capacitance in series: %f",cs);
printf ("\n Equivalent Capacitance in parallel: %f",cp);
getch();
}
Output

Enter The Capacitance c1,c2,c3:


246
Equivalent Capacitance in series: 1.090909
Equivalent Capacitance in parallel: 12.000000
Prepared by tptmagendiranatgmaildotcom

Page 11

GPT-KRISHNAGIRI-ECE-PART TIME 2017

11. Write C language program to find Resonant Frequency of RLC Series and Parallel Circuits.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float R,L,C,fs,fp;
clrscr();
printf ("Enter The R,L,C: \n");
scanf ("%f%f%f", &R,&L,&C);
fs=1/(2*3.14*sqrt(L*C));
fp=1/(2*3.14*sqrt(1/L*C)-pow(R/L,2));
printf ("\n Resonant frequency in series: %f",fs);
printf ("\n Resonant frequency in parallel: %f",fp);
getch();
}
Output
Enter The R,L,C:
246
Resonant frequency in series: 0.032504
Resonant frequency in parallel: 0.134383
12. Write C language program to find the power factor of series RL circuits.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float R,L,XL,F,Z,pf;
clrscr();
printf ("\n Enter The R,L,F:");
scanf ("%f%f%f",&R,&L,&F);
XL=2*3.14*F*L;
Z=sqrt(R*R+XL*XL);
pf=R/Z;
printf ("\n Power Factor in Series: %f",pf);
getch();
}
Output
Enter The R,L,F:
246
Power Factor in Series: 0.013268

Prepared by tptmagendiranatgmaildotcom

Page 12

GPT-KRISHNAGIRI-ECE-PART TIME 2017

13. Write C language program to find the Q factor for series and parallel resonant circuits.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float R,L,C,F,qfs,qfp;
clrscr();
printf ("Enter The R,L,C,F: \n");
scanf ("%f%f%f%f", &R,&L,&C,&F);
qfs=1/R*sqrt(1/C);
qfp=(2*3.14*F)/R;
printf ("\n Q FACTOR in series: %f",qfs);
printf ("\n Q FACTOR in parallel: %f",qfp);
getch();
}
Output
Enter The R,L,C,F:
2462
Q FACTOR in series: 0.204124
Q FACTOR in parallel: 6.280000

14. Write C language program to draw the symbol of NPN transistor using Graphics.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd = DETECT, gm;
initgraph(&gd,&gm, "c:\\tc\\bgi");
line(100, 100, 100, 200);
line(70, 150, 100, 150);
line(100, 125, 150, 90);
line(100, 175, 150, 210);
line(140, 190, 150, 210);
line(130, 210, 150, 210);
outtextxy(100, 250, "NPN Transistor");
getch();
closegraph();
}

Prepared by tptmagendiranatgmaildotcom

Page 13

GPT-KRISHNAGIRI-ECE-PART TIME 2017

15.Write C language program to draw the symbol of Diode using Graphics.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm, "c:\\tc\\bgi");
printf("C language program to draw the symbol of Diode using Graphics \n");
line(200,200,200,400);
line(140,300,200,300);
line(200,200,300,300);
line(200,400,300,300);
line(300,200,300,400);
line(300,300,500,300);
getch();
closegraph();
}

Prepared by tptmagendiranatgmaildotcom

Page 14

You might also like