Ppsuc Manual r20
Ppsuc Manual r20
M1. To produce high quality Electrical and Electronics Engineering graduates with
the requisite theoretical and practical knowledge.
M2. To undertake research & development and extension activities in the field of
Electrical and Electronics Engineering in the area of relevance for immediate
application as well as for establishing and strengthening the fundamental
knowledge.
M3. To create social awareness and ethical values in the graduates so as to contribute
in the progress of the society.
PEO 1 Provide necessary domain knowledge in the field of electrical and electronics
engineering to deal with their challenges solve engineering problems, pursue higher
education and research.
PEO 2 Able to apply theoretical and practical engineering knowledge
i) Towards innovation and entrepreneurship that caters the needs of industry and
society.
ii) To inculcate an attitude of lifelong learning.
PEO 3 Act as team member and team leader and work effectively to develop and design
multidisciplinary projects.
PEO 4 Able to acquire social responsibility and ethical values towards the growth and
development of society.
Program Outcomes (PO’s): -
The graduates of the program will, upon the, completion of program demonstrate
the abilityto -
PO1 Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO3 Design/development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO4 Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.
PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
PO7 Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
PO9 Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend
and write effective reports and design documentation, make effective presentations, and
give and receive clear instructions.
PO11 Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
Program Specific Outcomes (PSO’s)
PSO 1 Able to apply the knowledge gained from Mathematics, stochastic, foundational
computing and sciences to formulate practical problems of industry relevance with
research focus.
PSO 2 Able to apply technical knowledge and usage of modern hardware & software
tools related to Electrical & Electronics engineering for solving problems of social
relevance.
PSO 3 Able to analyze, comprehend, design, develop innovative applications for
demonstrating professional expertise, entrepreneurship and develop intellectual
property for nation building.
Mapping:
Mapping of PEO’s with Mission of the department:
2 Exercise 2:
4. Write a C program to calculate the distance between the two points.
5. Write a C program that accepts 4 integers p, q, r, s from the user
where r and s are positive and p is even. If q is greater than r and s
is greater than p and if the sum of r and s is greater than the sum
of p and q print "Correct values", otherwise print "Wrong
values".
3 Exercise 3:
6. Write a C program to convert a string to a long integer.
7. Write a program in C which is a Menu-Driven Program to
compute the area of the various geometrical shape.
8. Write a C program to calculate the factorial of a given number.
4 Exercise 4:
9. Write a program in C to display the n terms of even natural
numbers and their sum.
10. Write a program in C to display the n terms of harmonic series
and their sum.
1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms.
11. Write a C program to check whether a given number is an
Armstrong number or not.
5 Exercise 5:
12. Write a program in C to print all unique elements in an array.
13. Write a program in C to separate odd and even integers in
separate arrays.
14. Write a program in C to sort elements of array in ascending order.
6 Exercise 6:
15. Write a program in C for multiplication of two squareMatrices.
16. Write a program in C to find transpose of a given matrix.
17. Write a program in C to find inverse of a given matrix.
7 Exercise 7:
18. Write a program in C to search an element in a row wise and
column wise sorted matrix.
19. Write a program in C to print individual characters of string in
reverse order.
8 Exercise 8:
20. Write a program in C to compare two strings without using
string library functions.
21. Write a program in C to copy one string to another string.
9 Exercise 9:
22. Write a C Program to Store Information Using Structures with
Dynamically Memory Allocation
23. Write a program in C to demonstrate how to handle the pointers in
the program.
10 Exercise 10:
24. Write a program in C to demonstrate the use of & (addressof) and
*(value at address) operator.
25. Write a program in C to add two numbers using pointers.
11 Exercise 11:
26. Write a program in C to add numbers using call by reference.
27. Write a program in C to find the largest element using Dynamic
Memory Allocation.
12 Exercise 12:
28. Write a program in C to swap elements using call byreference.
29. Write a program in C to count the number of vowels and consonants
in a string using a pointer.
13 Exercise 13:
30. Write a program in C to show how a function returning pointer.
31. Write a C program to find sum of n elements entered by user. To
perform this program, allocate memory dynamically using malloc( )
function.
14 Exercise 14:
32. Write a C program to find sum of n elements entered by user. To
perform this program, allocate memory dynamically using calloc( )
function. Understand the difference between the above two
programs
33. Write a program in C to convert decimal number to binary number
using the function.
15 Exercise 15:
34. Write a program in C to check whether a number is a prime
number or not using the function.
35. Write a program in C to get the largest element of an array using
the function.
16 Exercise 16:
36. Write a program in C to append multiple lines at the end of a text
file.
37. Write a program in C to copy a file in another name.
38. Write a program in C to remove a file from the disk.
17 Exercise 17:
39. Write a program to create a data file.
40. Write a program to calculate the resonant frequencyof an RLC series
circuit.
18 Exercise 18:
41. Write a program to solve sin x, cos x, tan x expressed in
exponential form where x is in radians – (i) 𝜋 (ii) 𝜋/6.
4
42. Write a program to draw a graph for y = mx + C where the
constants ’m’ and ‘C’ are defined and ‘x’ varies from 0 to 20at
intervals of 2 units.
43. Write a program to solve for ’x’, if 2 log x = 4 log 3.
Instructions to students: -
Before entering the lab the student should carry the following things (MANDATORY)
Identity card issued by the college.
Class notes
Lab observation book
Lab Manual
Lab Record
Student must sign in and sign out in the register provided when attending the lab session
without fail.
Come to the laboratory in time. Students, who are late more than 15 min., will not be
allowed to attend the lab.
Students need to maintain 100% attendance in lab if not a strict action will be taken.
All students must follow a Dress Code while in the laboratory
Foods, drinks are NOT allowed.
All bags must be left at the indicated place.
Refer to the lab staff if you need any help in using the lab.
Respect the laboratory and its other users.
Workspace must be kept clean and tidy after experiment is completed.
Read the Manual carefully before coming to the laboratory and be sure about what you
are supposed to do.
Do the experiments as per the instructions given in the manual.
Copy all the programs to observation which are taught in class before attending the lab
session.
Students are not supposed to use floppy disks, pen drives without permission of lab- in
charge.
Lab records need to be submitted on or before the date of submission.
Introduction about lab
Steps involved in program development: -
To develop the program in high level language and translate it into machine level language
following steps have to be practiced.
Algorithm: -
It is a method of representing the step by step process for solving a problem. Each step is
called an instruction.
About C language
C is a programming language developed by Dennis Ritchie at AT&T‟s BELL Laboratory of
USA in 1972. Because of its reliability, C is very popular. C is highly portable & it is well
suited for structured programming. C program consists of collection of functions
History of C
The milestones in C's development as a language are listed below:
2. A new language “B” was attempted c. 1970 by Ken Thompson at Bell Labs.
3. UNIX was developed c. 1970 using “B” - DEC PDP-7 Assembly Language.
GCC: -
GCC is a Linux-based C compiler released by the Free Software Foundation which is usually
operated via the command line. It often comes distributed freely with a Linux installation, so
if you are running UNIX or a Linux variant you will probably have it on your system. You
can invoke GCC on a source code file
simply by typing: -
gcc filename
The default executable output of GCC is "a.out", which can be run by typing “./a.out”. It is
also possible to specify a name for the executable file at the command line by using the syntax
“ -o outputfile” , as shown in the following
example : -
Again, you can run your program with "./outputfile". (The ./ is there to ensure you run the
program for the current working directory.)
Note: If you need to use functions from the math library (generally functions from “math.h”
such as sin or sqrt), then you need to explicitly ask it to link with that library with the “ –l ”
flag and the library “m”:
Turbo C/C++
Open Turbo C/C++ from your Desktop or Programs menu. Select “File” from Menu bar and
select option “New” and Save C program with filename “.C” extension.
If the compilation is successful – you will see a “success” message. Else you will
To RUN the program – you may select ->Run from menu and click -> Run
Documentation section
Link section
Definition section
Declaration part
Executable part
SUBPROGRAM SECTION
Keywords: -
C has 32 keywords (reserved words with special meaning):
1. auto, 2. break, 3. case, 4. char, 5. const, 6. continue, 7. default, 8. do, 9. double, 10. else,
11. enum, 12. extern, 13. float, 14. for, 15. goto, 16. if, 17. int, 18. long, 19. register,
20. return, 21. short, 22. signed, 23. sizeof, 24. static, 25. struct, 26. switch, 27. typedef,
28. union, 29. unsigned, 30. void, 31. volatile, and 32. while.
Operators: -
C supports a rich set of operators, which are symbols used within an expression to specify the
manipulations to be performed while evaluating that expression. C has the following
operators:
arithmetic: +, -, *, /, %
assignment: =
augmented assignment: +=, - =, *=, /=, %=, &=, |=, ^=, <<=, >>=
conditional evaluation: ? :
equality testing: = =, !=
calling functions: ( )
sequencing: ,
subexpression grouping: ( )
A. Write a C program to print a block F using hash (#), where the F has a
height of six characters and width of five and four characters.
AIM: To print a block F using hash (#), where the F has a height of six characters and width of
five and four characters.
2. TURBO C
ALGORITHM: FLOWCHART:
Step 1: START
Step 2: printf("######\n")
Step 3: printf("#\n")
Step 4: printf("#\n")
Step 5: printf("#####\n")
Step 6: printf("#\n")
Step 7: printf("#\n")
Step 8: printf("#\n")
Step 9: STOP
PROGRAM:
#include <stdio.h>
#include<conio.h>
void main ()
{
printf("######\n");
printf("#\n");
printf("#\n");
printf("#####\n");
printf("#\n");
printf("#\n");
printf("#\n");
getch();
}
EXPERIMENT NO: 1
AIM: To Write a C program to compute the perimeter and area of a rectangle with a height of 7
inches and width of 5 inches
2. Turbo C
ALGORITHM:
Step 1: Start
Step 2: Initialize int width and height as 5 inches, 7 inches, area, and perimeter
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
/* height and width of a rectangle in inches */
int width;
int height;
int area;
int perimeter;
void main()
{
height = 7;
width = 5;
clrscr();
perimeter = 2*(height + width);
printf("Perimeter of the rectangle = %d inches\n", perimeter);
area = height * width;
printf("Area of the rectangle = %d square inches\n", area);
getch();
}
EXPERIMENT NO: 1
2. Turbo C
ALGORITHM: FLOWCHART
Step 1: Start
#include <stdio.h>
#include <conio.h>
void main()
{
int a = 125, b = 12345;
long ax = 1234567890;
short s = 4043;
float x = 2.13459;
double dx = 1.1415927;
char c = 'W';
unsigned long ux = 2541567890;
printf("a + c = %d\n", a + c);
printf("x + c = %f\n", x + c);
printf("dx + x = %f\n", dx + x);
printf("((int) dx) + ax = %ld\n", ((int) dx) + ax);
printf("a + x = %f\n", a + x);
printf("s + b = %d\n", s + b);
printf("ax + b = %ld\n", ax + b);
printf("s + c = %hd\n", s + c);
printf("ax + c = %ld\n", ax + c);
printf("ax + ux = %lu\n", ax + ux);
getch();
}
EXPERIMENT NO: 2
AIM: To write a C program to calculate the distance between the two points.
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Step 6: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
float x1, y1, x2, y2, gdistance;
clrscr();
printf("Input x1: ");
scanf("%f", &x1);
printf("Input y1: ");
scanf("%f", &y1);
printf("Input x2: ");
scanf("%f", &x2);
printf("Input y2: ");
scanf("%f", &y2);
gdistance = ((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1));
printf("Distance between the said points: %.4f", sqrt(gdistance));
printf("\n");
getch();
}
EXPERIMENT NO: 2
B. Write a C program that accepts 4 integers p, q, r, s from the user where r and s
are positive and p is even. If q is greater than r and s is greater than p and if
the sum of r and s is greater than the sum of p and q print "Correct values",
otherwise print "Wrong values".
AIM: To write a c program such that it accepts 4 integers and prints correct values if they are
according to given conditions else prints wrong values
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Step 6: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int p, q, r, s;
clrscr();
printf("\nInput the first integer: ");
scanf("%d", &p);
printf("\nInput the second integer: ");
scanf("%d", &q);
printf("\nInput the third integer: ");
scanf("%d", &r);
printf("\nInput the fourth integer: ");
scanf("%d", &s);
if((q > r) && (s > p) && ((r+s) > (p+q)) && (r > 0) && (s > 0) && (p%2 == 0))
{
printf("\nCorrect values\n");
}
else {
printf("\nWrong values\n");
}
getch();
}
EXPERIMENT NO: 3
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Step 5: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
char inputString[20];
clrscr();
printf("Enter a String for long Integer conversion\n");
gets(inputString);
printf("Integer: %ld \n", atoi(inputString));
getch();
}
EXPERIMENT NO: 3
AIM: To write a program in C which is a Menu-Driven Program to compute the area of the
various geometrical shape
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Case 2:
Print input length and width of rectangle
Take input using scanf function
Compute area =l*w
Case 3:
Print input base and height of triangle
Take input using scanf function
Compute area =0.5*b*h
Step 6: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
int choice,r,l,w,b,h;
float area;
clrscr();
printf("Input 1 for area of circle\n");
printf("Input 2 for area of rectangle\n");
printf("Input 3 for area of triangle\n");
printf("Input your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Input radious of the circle : ");
scanf("%d",&r);
area=3.14*r*r;
break;
case 2:
printf("Input length and width of the rectangle : ");
scanf("%d%d",&l,&w);
area=l*w;
break;
case 3:
printf("Input the base and hight of the triangle :");
scanf("%d%d",&b,&h);
area=.5*b*h;
break;
}
printf("The area is : %f\n",area);
getch();
}
EXPERIMENT NO: 3
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Step 6: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
int i,f=1,num;
clrscr();
printf("Input the number : ");
scanf("%d",&num);
for(i=1;i<=num;i++)
f=f*i;
printf("The Factorial of %d is: %d\n", num, f);
getch();
}
EXPERIMENT NO: 4
AIM: To write a program in C to display the n terms of even natural number and their sum
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Step 6: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main() {
int i,n,sum=0;
clrscr();
printf("Input number of terms : ");
scanf("%d",&n);
printf("\nThe even numbers are :");
for(i=1;i<=n;i++)
{
printf("%d ",2*i);
sum+=2*i;
}
printf("\nThe Sum of even Natural Number upto %d terms : %d \n",n,sum);
getch();
}
EXPERIMENT NO: 4
AIM: To write a program in C to display the n terms of harmonic series and their sum. 1 + 1/2 +
1/3 + 1/4 + 1/5 ... 1/n terms.
2. Turbo C
ALGORITHM:
Step 1: START
Step 3: Using for loop display the harmonic series and calculate sum.
Step 5: STOP
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int i,n;
float s=0.0;
clrscr();
printf("Input the number of terms : ");
scanf("%d",&n);
printf("\n\n");
for(i=1;i<=n;i++)
{
if(i<n)
{
printf("1/%d + ",i);
s+=1/(float)i;
}
if(i==n)
{
printf("1/%d ",i);
s+=1/(float)i;
}
}
printf("\nSum of Series upto %d terms : %f \n",n,s);
getch();
}
EXPERIMENT NO: 4
AIM: To write a C program to check whether a given number is an Armstrong number or not.
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
#include <stdio.h>
#include <conio.h>
int main()
{
int r, n, temp, sum=0;
printf("Enter a positive integer: ");
scanf("%d", &n);
temp=n;
while(n1!=0)
{
r=n%10;
sum=sum+r*r*r;
n=n/10;
}
if(temp==sum)
printf("%d is an Armstrong number.",n);
else
printf("%d is not an Armstrong number.",n);
getch();
}
EXPERIMENT NO: 5
2. Turbo C
ALGORITHM:
Step 1: Start
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main() {
int arr1[100], n,ctr=0;
int i, j, k;
clrscr();
printf("\n\nPrint all unique elements of an array:\n");
printf("------------------------------------------\n");
printf("Input the number of elements to be stored in the array: ");
scanf("%d",&n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)
{
printf("element - %d : ",i);
scanf("%d",&arr1[i]);
}
printf("\nThe unique elements found in the array are: \n");
for(i=0; i<n; i++)
{
ctr=0;
for(j=0,k=n; j<k+1; j++)
{
/*Increment the counter when the search value is duplicate.*/
if (i!=j)
{
if(arr1[i]==arr1[j])
{
ctr++;
}
}
}
if(ctr==0)
{
printf("%d ",arr1[i]);
}
}
printf("\n\n");
getch();
}
EXPERIMENT NO: 5
AIM: Write a program in C to separate odd and even integers in separate arrays.
2. Turbo C
ALGORITHM:
Step 1: Start
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int arr1[10], arr2[10], arr3[10];
int i,j=0,k=0,n;
clrscr();
printf("\n\nSeparate odd and even integers in separate arrays:\n");
printf("------------------------------------------------------\n");
printf("Input the number of elements to be stored in the array :");
scanf("%d",&n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)
{
printf("element - %d : ",i);
scanf("%d",&arr1[i]);
}
for(i=0;i<n;i++)
{
if (arr1[i]%2 == 0)
{
arr2[j] = arr1[i];
j++;
}
else
{
arr3[k] = arr1[i];
k++;
}
}
printf("\nThe Even elements are : \n");
for(i=0;i<j;i++)
{
printf("%d ",arr2[i]);
}
printf("\nThe Odd elements are :\n");
for(i=0;i<k;i++)
{
printf("%d ", arr3[i]);
}
printf("\n\n");
getch();
}
EXPERIMENT NO: 5
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Using for loop i from 0 to n-1,by using one more for loop j in j from i+1 to n to sort.
Step 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int arr1[100];
int n, i, j, temp;
clrscr();
printf("\n\nsort elements of array in ascending order :\n ");
printf("----------------------------------------------\n");
printf("Input the size of array : ");
scanf("%d", &n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)
{
printf("element - %d : ",i);
scanf("%d",&arr1[i]);
}
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
if(arr1[j] <arr1[i])
{
temp = arr1[i];
arr1[i] = arr1[j];
arr1[j] = tmp;
}
}
}
printf("\nElements of array in sorted ascending order:\n");
for(i=0; i<n; i++)
{
printf("%d ", arr1[i]);
}
printf("\n\n");
getch();
}
EXPERIMENT NO: 6
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Multiply the first row of first matrix and first column of second matrix
Step 7: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main() {
int arr1[50][50],brr1[50][50],crr1[50][50],i,j,k,r1,c1,r2,c2,sum=0;
clrscr() ;
printf("\n\nMultiplication of two Matrices :\n");
printf("----------------------------------\n");
printf("\nInput the rows and columns of first matrix : ");
scanf("%d %d",&r1,&c1);
printf("\nInput the rows and columns of second matrix : ");
scanf("%d %d",&r2,&c2);
if(c1!=r2)
{
printf("Mutiplication of Matrix is not possible.");
printf("\nColumn of first matrix and row of second matrix must be same.");
}
else
{
printf("Input elements in the first matrix :\n");
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
printf("element - [%d],[%d] : ",i,j);
scanf("%d",&arr1[i][j]);
}
}
printf("Input elements in the second matrix :\n");
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
printf("element - [%d],[%d] : ",i,j);
scanf("%d",&brr1[i][j]);
}
}
printf("\nThe First matrix is :\n");
for(i=0;i<r1;i++)
{
printf("\n");
for(j=0;j<c1;j++)
printf("%d\t",arr1[i][j]);
}
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Store the elements of arr1 such that brr1[j][i]=arr1[i][j] that is in reverse manner using a
for loop
Step 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
main()
{
int arr1[50][50],brr1[50][50],i,j,r,c;
clrscr();
printf("\n\nTranspose of a Matrix :\n");
printf("---------------------------\n");
printf("\nInput the rows and columns of the matrix : ");
scanf("%d %d",&r,&c);
printf("Input elements in the first matrix :\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("element - [%d],[%d] : ",i,j);
scanf("%d",&arr1[i][j]);
}
}
printf("\nThe matrix is :\n");
for(i=0;i<r;i++)
{
printf("\n");
for(j=0;j<c;j++)
printf("%d\t",arr1[i][j]);
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
brr1[j][i]=arr1[i][j];
}
}
printf("\n\nThe transpose of a matrix is : ");
for(i=0;i<c;i++){
printf("\n");
for(j=0;j<r;j++){
printf("%d\t",brr1[i][j]);
}
}
printf("\n\n");
getch();
}
EXPERIMENT NO: 6
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Calculate determinant and cofactor matrix and print inverse of matrix
Step 5: STOP
FLOWCHART:
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int a[3][3],i,j;
float determinant=0;
printf("Enter the 9 elements of matrix: ");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("\nThe matrix is\n");
for(i=0;i<3;i++){
printf("\n");
for(j=0;j<3;j++)
printf("%d\t",a[i][j]);
}
for(i=0;i<3;i++)
determinant = determinant + (a[0][i]*(a[1][(i+1)%3]*a[2][(i+2)%3] -
a[1][(i+2)%3]*a[2][(i+1)%3]));
printf("\nInverse of matrix is: \n\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++)
printf("%.2f\t",((a[(i+1)%3][(j+1)%3] * a[(i+2)%3][(j+2)%3]) -
(a[(i+1)%3][(j+2)%3]*a[(i+2)%3][(j+1)%3]))/ determinant);
printf("\n");
}
return 0;
}
SAMPLE OUTPUT:
EXPERIMENT NO: 7
AIM: To write a program in C to search an element in a row wise and column wise sorted matrix
2. Turbo C
ALGORITHM:
Step 1: Start
Step 8: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
int searchElement(int arr2D[4][4], int n, int x)
{
int i = 0, j = n-1;
clrscr();
while ( i < n && j >= 0 )
{
if ( arr2D[i][j] == x )
{
printf("\nThe element Found at the position in the matrix is: %d, %d", i, j);
return 1;
}
if ( arr2D[i][j] < x )
j--;
else
i++;
}
printf("\nThe given element not found in the 2D array.");
return 0;
}
int main()
{
int arr2D[4][4] = { {15, 23, 31, 39},
{18, 26, 36, 43},
{25, 28, 37, 48},
{30, 34, 39, 50},
};
int i,j,v;
v=37;
//------------- print original array ------------------
printf("The given array in matrix form is : \n");
for(i = 0; i < 4; i++)
{
for (j=0;j<4;j++)
{
printf("%d ", arr2D[i][j]);
}
printf("\n");
}
//------------------------------------------------------
printf("The given value for searching
is:%d",v);
searchElement(arr2D, 4, v);
getch();
}
EXPERIMENT NO: 7
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Using for loop get individual characters of string in reverse order.
Step 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include<string.h>
void main() {
char str[100]; /* Declares a string of size 100 */
int l,i;
clrscr();
printf("\n\nPrint individual characters of string in reverse order :\n");
printf("------------------------------------------------------\n");
printf("Input the string : ");
fgets(str, sizeof str, stdin);
l=strlen(str);
printf("The characters of the string in reverse are : \n");
for(i=l;i>=0;i--)
{
printf("%c ", str[i]);
}
printf("\n");
getch();
OUTPUT:
EXPERIMENT NO: 8
2. Turbo C
ALGORITHM:
Step 1: Start
Step7: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int p, q, r;
int i = 0, j = 0;
char str1[1000];
char str2[1000];
clrscr();
printf("Enter the 1st string which is to be compared with 2nd string\n");
scanf("%s", &str1);
printf("Enter the 2nd string which is to be compared with 1st string\n");
scanf("%s", &str2);
printf("The first string is %s\n", str1);
printf("The second string is %s\n", str2);
while (str1[i] != '\0')
{
p++;
i++;
}
printf("The length of str1 is %d\n", p);
while (str2[j] != '\0')
{
q++;
j++;
}
printf("The length of str2 is %d\n", q);
if (p == q)
{
for (i = 0, j = 0; i < p, j < q; i++, j++)
{
if (str1[i] == str2[j])
{
r++;
}
}
printf("The common length of two strings is %d\n",r);
if (p != r || p > r || p < r || q > r || q < r || q != r)
{
printf("The given two strings %s and %s are not equal\n", str1, str2);
}
}
if (p == r && q == r)
{
printf("The given two strings %s and %s are equal\n", str1, str2);
}
getch();
}
EXPERIMENT NO: 8
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Using strcpy(“target”, “source”) and print the string using printf function
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char str1[1000];
char str2[1000];
clrscr();
printf("Enter the first string\n");
scanf("%s",&str1);
printf("Enter the second string\n");
scanf("%s",&str2);
printf("The string 1 is %s\n",str1);
printf("The string 2 is %s\n",str2);
printf("The first string after copying second string to first string is %s\n", strcpy(str1,str2));
getch();
}
SAMPLE OUTPUT
EXPERIMENT NO: 9
AIM: To write a C Program to Store Information Using Structures with Dynamically Memory
Allocation
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Create the dynamic memory allocation using ptr = (struct course *)malloc(no of
Records * sizeof(struct course));
Step 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
struct course {
int marks;
char subject[30];
};
void main() {
struct course *ptr;
int noOfRecords;
clrscr();
printf("Enter the number of records: ");
scanf("%d", &noOfRecords);
printf("Displaying Information:\n");
for (int i = 0; i < noOfRecords; ++i) {
printf("%s\t%d\n", (ptr + i)->subject, (ptr + i)->marks);
}
free(ptr);
getch();
}
SAMPLE OUTPUT:
Displaying Information:
Science 82
DSA 73
EXPERIMENT NO: 9
AIM: To write a program in C to demonstrate how to handle the pointers in the program
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Case 1 store ab=&m print address and value stored in the ab
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
int* ab;
int m;
m=29;
clrscr();
printf("\n\n Pointer : How to handle the pointers in the program :\n");
printf("------------------------------------------------------------\n");
printf(" Here in the declaration ab = int pointer, int m= 29\n\n");
printf(" Address of m : %p\n",&m);
printf(" Value of m : %d\n\n",m);
ab=&m;
printf(" Now ab is assigned with the address of m.\n");
printf(" Address of pointer ab : %p\n",ab);
printf(" Content of pointer ab : %d\n\n",*ab);
m=34;
printf(" The value of m assigned to 34 now.\n");
printf(" Address of pointer ab : %p\n",ab);
printf(" Content of pointer ab : %d\n\n",*ab);
*ab=7;
printf(" The pointer variable ab is assigned the value 7 now.\n");
printf(" Address of m : %p\n",&m);//as ab contain the address of m
//so *ab changed the value of m and now m become 7
printf(" Value of m : %d\n\n",m);
getch();
}
EXPERIMENT NO: 10
AIM: To write a program in C to demonstrate the use of & (address of) and *(value at address)
operator
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Initialize 3 pointers int*pt1, float*pt2, char*pt3 and pt1=&m, pt2=&fx and pt3=&cht
Step 4: Print address, value of the operators with different combinations of & and *
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
int m=300;
float fx = 300.60;
char cht = 'z';
printf("\n\n Pointer : Demonstrate the use of & and * operator :\n");
printf("--------------------------------------------------------\n");
int *pt1;
float *pt2;
char *pt3;
pt1= &m;
pt2=&fx;
pt3=&cht;
printf ( " m = %d\n",m);
printf ( " fx = %f\n",fx);
printf ( " cht = %c\n",cht);
printf("\n Using & operator :\n");
printf("-----------------------\n");
printf ( " address of m = %p\n",&m);
printf ( " address of fx = %p\n",&fx);
printf ( " address of cht = %p\n",&cht);
printf("\n Using & and * operator :\n");
printf("-----------------------------\n");
printf ( " value at address of m = %d\n",*(&m));
printf ( " value at address of fx = %f\n",*(&fx));
printf ( " value at address of cht = %c\n",*(&cht));
printf("\n Using only pointer variable :\n");
printf("----------------------------------\n");
printf ( " address of m = %p\n",pt1);
printf ( " address of fx = %p\n",pt2);
printf ( " address of cht = %p\n",pt3);
printf("\n Using only pointer operator :\n");
printf("----------------------------------\n");
printf ( " value at address of m = %d\n",*pt1);
printf ( " value at address of fx= %f\n",*pt2);
printf ( " value at address of cht= %c\n\n",*pt3);
getch();
}
EXPERIMENT NO: 10
2. Turbo C
ALGORITHM:
Step 1: Start
Step 2: Declare a function with name add with 2 pointer variables int*i and int *j
Step 6: Stop
FLOWCHART:
PROGRAM:
#include<stdio.h>
int add(int *i,int *j);
int main(){
int a,b,*i,*j;
int addition;
clrscr();
i=&a;
j=&b;
printf("Enter the two numbers which are to be added using pointers\n");
scanf("%d%d",&a,&b);
add(&a,&b);
addition = add(&a,&b);
printf("The addition of given two numbers %d and %d is %d which is caluclated using
pointers\n",a,b,addition);
getch();
}
int add(int *i,int *j){
return *i+*j; }
OUTPUT:
EXPERIMENT NO: 11
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Pass the arguments to addTwoNumbers as address and receive them as pointer variables.
Step 5: Return the addition of those two pointer variables and print that sum
Step 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
long fno, sno, sum;
clrscr();
printf("\n\n Pointer : Add two numbers using call by reference:\n");
printf("-------------------------------------------------------\n");
printf(" Input the first number : ");
scanf("%ld", &fno);
printf(" Input the second number : ");
scanf("%ld", &sno);
sum = addTwoNumbers(&fno, &sno);
printf(" The sum of %ld and %ld is %ld\n\n", fno, sno, sum);
getch();
}
long addTwoNumbers(long *n1, long *n2)
{
long sum;
sum = *n1 + *n2;
return sum;
}
EXPERIMENT NO: 11
AIM: To program in C to find the largest element using Dynamic Memory Allocation
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Input total number of elements using scanf function to allocate size for those elements
Step 6: enter the elements using a for loop and a scanf function
STEP 8: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main() {
int i,n;
float *element;
clrscr();
printf("\n\n Pointer : Find the largest element using Dynamic Memory Allocation :\n");
printf("-------------------------------------------------------------------------\n");
printf(" Input total number of elements(1 to 100): ");
scanf("%d",&n);
element=(float*)calloc(n,sizeof(float)); // Memory is allocated for 'n' elements
if(element==NULL)
{
printf(" No memory is allocated.");
exit(0);
}
printf("\n");
for(i=0;i<n;++i)
{
printf(" Number %d: ",i+1);
scanf("%f",element+i);
}
for(i=1;i<n;++i)
{
if(*element<*(element+i))
*element=*(element+i);
}
printf(" The Largest element is : %.2f \n\n",*element);
getch();
}
EXPERIMENT NO: 12
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Read elements using scanf function print the value before swapping
FLOWCHART:
PROGRAM:
#include<stdio.h>
#include<conio.h>
int swap(int *x,int *y);
int main()
{
int a,b;
clrscr();
printf("Enter the values of 'a' and 'b' :\n");
scanf("%d%d",&a,&b);
printf("The values of 'a' and 'b' before swapping is %d and %d\n",a,b);
swap(&a,&b);
}
int swap(int *x , int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
printf("The value of 'a' and 'b' after swapping is %d and %d",*x,*y);
getch();
}
OUTPUT:
EXPERIMENT NO: 12
AIM: To write a program in C to count the number of vowels and consonants in a string using a
pointer
2. Turbo C
ALGORITHM:
Step 1: Start
Step 2: Create 2 functions such that they count no of vowels and no of consonants
Step 4: Pass that string to the strvowel and strconsonant functions created
Step 6: Enter the ascii values of the vowels and if the ascii values are matched then increase the
count of vowels and print the vowel and it’s position
Step 7: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <string.h>
void strvowel(char *ptr);
void strconsonant(char *ptr);
int main()
{
char name[100];
clrscr();
printf("Enter the string in which vowels and consonats are to be counted\n");
scanf("%s", &name);
printf("The entered string is %s\n", name);
strvowel(name);
strconsonant(name);
return 0;
}
void strvowel(char *ptr)
{
int x;
int i;
int countvowel = 0;
for (i = 0; i < strlen(ptr); i++)
{
x = (int)(ptr[i]);/*conversion of string to integers which are equal to ascii value*/
if (64 < x < 123 && (x == 65 || x == 69 || x == 73 || x == 79 || x == 85 || x == 97 || x == 101
|| x == 105 || x == 111 || x == 117))
{
countvowel++;
printf("The vowel--%d is %c\n",i+1,ptr[i]);
}
}
if(countvowel==strlen(ptr)){
printf("There are no consonants in the given string\n");
}
printf("The number of vowels is %d\n", countvowel);
}
void strconsonant(char *ptr)
{
int x;
int i;
int countconsonant = 0;
for (i = 0; i < strlen(ptr); i++)
{
x = (int)(ptr[i]);/*conversion of string to integers which are equal to ascii value*/
if (64 < x < 123 && x != 65 && x != 69 && x != 73 && x != 79&& x != 85 && x != 97
&& x != 101 && x != 105 && x != 111 && x != 117)
{
countconsonant++;
printf("The consonant--%d is %c\n",i+1,ptr[i]);
}
}
if(countconsonant==strlen(ptr)){
printf("There are no vowels in the given string\n");
}
!
printf("The number of consonants is %d\n", countconsonant);
}
OUTPUT:
EXPERIMENT NO: 13
2. Turbo C
ALGORITHM:
Step 1: Start
STEP 4: Pass those numbers to the function int * find Larger() and check the condition
if(*n1 > *n2)
return n1;
else
return n2;
Step 5: Print the result
STEP 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include<conio.h>
int* findLarger(int*, int*);
void main()
{
int numa=0;
int numb=0;
int *result;
clrscr();
printf("\n\n Pointer : Show a function returning pointer :\n");
printf("--------------------------------------------------\n");
printf(" Input the first number : ");
scanf("%d", &numa);
printf(" Input the second number : ");
scanf("%d", &numb);
result=findLarger(&numa, &numb);
printf(" The number %d is larger. \n\n",*result);
getch();
}
int* findLarger(int *n1, int *n2)
{
if(*n1 > *n2)
return n1;
else
return n2;
}
EXPERIMENT NO: 13
AIM: To write C program to find sum of n elements entered by user. To perform this program,
allocate memory dynamically using malloc( ) function.
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Allocate memory using malloc() function ptr= (int*) malloc (num*sizeof(int));
Step 4: Enter elements and while entering the numbers add them and store them into sum.
STEP 6: Stop
FLOWCHART:
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int num, i, *ptr, sum=0;
printf("Enter total number of elements(1 to 100): ");
scanf("%d", &num);
// memory allocated using malloc()
ptr= (int*) malloc (num*sizeof(int));
if(ptr==NULL)
{
printf("Memory not allocated.");
return EXIT_FAILURE;
}
printf("Enter elements :\n");
for(i=0;i<num;i++)
{
scanf("%d",ptr+i);
sum += *(ptr+i);
}
printf("Sum= %d",sum);
free(ptr);
getch();
}
OUTPUT:
EXPERIMENT NO: 14
AIM: To write a C program to find sum of n elements entered by user. To perform this program,
allocate memory dynamically using calloc( ) function. Understand the difference between the
above two programs
2. Turbo C
ALGORITHM:
Step 1: Start
Step 4: Ptr=(int*)calloc(n,sizeof(int));
Store the numbers using a for loop and enter the values using scanf function
Step 5: For every run add the numbers to sum and store the sum value in the sum variable.
Step 7: Stop
FLOWCHART:
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int n,i,*ptr,sum=0;
printf("Enter number of elements: ");
scanf("%d",&n);
ptr=(int*)calloc(n,sizeof(int)); //memory allocated using calloc
if(ptr==NULL)
{
printf("Sorry! unable to allocate memory");
exit(0);
}
printf("Enter elements of array: ");
for(i=0;i<n;++i)
{
scanf("%d",ptr+i);
sum+=*(ptr+i);
}
printf("Sum=%d",sum);
free(ptr);
getch();
}
Calloc() : The calloc() function allocates multiple block of requested memory. It initially
initialize all bytes to zero.
Malloc() : The malloc() function allocates single block of requested memory. It doesn't initialize
memory at execution time, so it has garbage value initially.
OUTPUT:
EXPERIMENT NO: 14
AIM: to write a program in C to convert decimal number to binary number using the function.
2. Turbo C
ALGORITHM:
Step 1: Start
Step 2: Divide the number by through % operator and store the remainder in array
Step 6: Stop
FLOWCHART:
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(){
int a[10],n,i;
clrscr();
system ("cls");
printf("Enter the number to convert: ");
scanf("%d",&n);
for(i=0;n>0;i++)
{
a[i]=n%2;
n=n/2;
}
printf("\nBinary of Given Number is=");
for(i=i-1;i>=0;i--)
{
printf("%d",a[i]);
}
getch();
}
OUTPUT:
EXPERIMENT NO: 15
AIM: To write a program in C to check whether a number is a prime number or not using the
function
2. Turbo C
ALGORITHM:
Step 1: Start
Step 2: Declare a function and initialize int num, res=0, read a number.
Step 3: Call a function for prime no.
Step 5: If result is zero print prime no, Else print not a prime no.
Step 6: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int num,res=0;
clrscr();
printf("\nENTER A NUMBER: ");
scanf("%d",&num);
res=prime(num);
if(res==0)
printf("\n%d IS A PRIME NUMBER",num);
else
printf("\n%d IS NOT A PRIME NUMBER",num);
getch();
}
int prime(int n)
{
int i;
for(i=2;i<=n/2;i++)
{
if(n%i!=0)
continue;
else return 1;
}
return 0;
}
OUTPUT:
EXPERIMENT NO: 15
B. Write a program in C to get the largest element of an array using the function
AIM: To write a program in C to get the largest element of an array using the function
2. Turbo C
ALGORITHM:
Step 1: Start
Step 2: Enter the size of array and using a for loop enter the elements into the array using scanf
function
Step 4: Using for loop find the largest value and receive largest no from function.
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include<conio.h>
int findLarge(int[],int);
int main()
{
int a[100],a_size,L_Num,i;
clrscr();
printf(“Enter size of array: “);
scanf(“%d”,&a_size);
printf(“Enter the elements into array:\n”);
for(i=0;i<a_size;i++)
scanf(“%d”,&a[i]);
L_Num=findLarge(a,a_size);
printf(“Largest number is: %d\n”,L_Num);
getch();
}
int findLarge(int a[],int a_size)
{
int i,Large_num;
Large_num=a[0];
for(i=1;i<a_size;i++)
{
if(Large_num<a[i])
Large_num=a[i];
}
return Large_num;
}
OUTPUT:
EXPERIMENT NO: 16
AIM: To write a program in c to append multiple lines at the end of a text file
2. Turbo C
ALGORITHM:
Step 1: Start
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include<conio.h>
int main ()
{
FILE * fptr;
int i,n;
char str[100];
char fname[20];
char str1;
clrscr();
printf("\n\n Append multiple lines at the end of a text file :\n");
printf(" Input the file name to be opened : ");
scanf("%s",fname);
fptr = fopen(fname, "a");
printf(" Input the number of lines to be written : ");
scanf("%d", &n);
printf(" The lines are : \n");
for(i = 0; i< n+1;i++)
{
fgets(str, sizeof str, stdin);
fputs(str, fptr);
}
fclose (fptr);
//----- Read the file after appended -------
fptr = fopen (fname, "r");
printf("\n The content of the file %s is :\n",fname);
str1 = fgetc(fptr);
while (str1 != EOF)
{
printf ("%c", str1); OUTPUT:
str1 = fgetc(fptr);
}
printf("\n\n");
fclose (fptr);
getch();
}
EXPERIMENT NO: 16
2. Turbo C
ALGORITHM:
Step 1: Start
STEP 3: Using getc function get the contents of the file opened
STEP 4: Open the second file to which the contents are to be copied and copy them
STEP 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *fptr1, *fptr2;
char ch, fname1[20], fname2[20];
printf("\n\n Copy a file in another name :\n");
printf("----------------------------------\n");
printf(" Input the source file name : ");
scanf("%s",fname1);
fptr1=fopen(fname1, "r");
if(fptr1==NULL)
{
printf(" File does not found or error in opening.!!");
exit(1);
}
printf(" Input the new file name : ");
scanf("%s",fname2);
fptr2=fopen(fname2, "w");
if(fptr2==NULL)
{
printf(" File does not found or error in opening.!!");
fclose(fptr1);
exit(2);
}
while(1)
{
ch=fgetc(fptr1);
if(ch==EOF) OUTPUT:
{
break;
}
else
{
fputc(ch, fptr2);
}
}
printf(" The file %s copied successfully in the file %s. \n\n",fname1,fname2);
fclose(fptr1);
fclose(fptr2);
getchar();
}
EXPERIMENT NO: 16
2. Turbo C
ALGORITHM:
Step 1: Start
Step 3: Enter the file name which is to be removed using scanf function
Step 5: Stop
FLOWCHART:
PROGRAM:
#include <stdio.h>
void main()
{
int status;
char fname[20];
printf("\n\n Remove a file from the disk :\n");
printf("----------------------------------\n");
printf(" Input the name of file to delete : ");
scanf("%s",fname);
status=remove(fname);
if(status==0)
{
printf(" The file %s is deleted successfully..!!\n\n",fname);
}
else
{
printf(" Unable to delete file %s\n\n",fname);
}
}
EXPERIMENT NO: 17
2. Turbo C
ALGORITHM: FLOWCHART:
Step 1: Start
Step 9: Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
define data. Size 1000
main()
{
Char data (data-size);
FILE *fptr;
clrscr();
fptr = fopen("data \file | txt", "W");
if (fptr= = NULL)
{
printf (“unable to Create file ");
exit (EXIT_ FAILURE);
}
printf("Enter Contents to store in file: \n ");
fgets(data, data. Site, stdin);
fputs (data, fptr);
fclose(fptr);
printf("File Created and saved successfully ");
}
SAMPLE OUTPUT:
This is C lab
AIM: To write a c program to calculate the resonant frequency of an RLC series Circuit.
2. Turbo C++
ALGORITHM:
Step 1: Start
In Current function
In frequency function
Declare s,result
return f
Step 9: Stop
FLOWCHART:
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.142
double current (double);
double frequency (double, double);
main()
}
double r, l, c, I, f;
printf("Enter Value of R (ohm):");
scanf ("%\f", &r);
printf ("Enter value of L (henry):”);
scanf (“%\f", &i);
printf ("Enter value of C ((farad): ");
scanf ("%\f", &c);
i=current (r);
printf(" The value of current : %3\f”,i);
f=frequency(l, c);
printf(“ The value of frequency :%3\f”,f);
getch();
}
double Current (double, r)
{
double V=240, i;
i=v/r;
return i;
}
double frequency (double l, double C)
{
double S=0, result, f;
s=l*c
result = sqrt(s);
f=(1/2*pi*result);
return f;
SAMPLE OUTPUT:
Enter value of R (ohm): 5
Enter Value of L(henry):2
Enter value of C(farad):4
The Value of Current: 48.000
The Value of frequency: 0.065