0% found this document useful (0 votes)
27 views35 pages

PEPS-Practical File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views35 pages

PEPS-Practical File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

24CSE0104 - Programming for Engineering Problem

Solving

Practical File

Bachel

or of Engineering

(Electr

ical Engineering)

SUBMITTED BY

Vardaan Palta
2410996645

SUBMITTED TO
Dr. Abhishilpa Nandini
A

ssistant Professor

uly - Dec 2024


DEPARTMENT OF ELECTRICAL

ENGINEERING, CUIET-AE CHITKARA

UNIVERSITY, PUNJAB
Exercise 1.

Aim : Write a C++ Program to Print”Ohm’s


Law States that,At constant temperature,the

electric current(I) flowing through a fixed

linear resistance(R) is directly proportional to

the voltage(V) applied across it.”

Program :
#include <iostream>
using namespace std;
int main() {
cout << "Ohm's Law states that, At constant temperature, the electrical
current(I) "
"flowing through a fixed linear resistance(R) is directly proportional to "
"the voltage(V) applied across it." << endl;
return 0;
}

Output :

Exercise 2.

Aim : Write a C++ program To Print Wire Size


selection Table.

Program :
#include<iostream>
using namespace std;
int main(){
std::cout<<"wire size (AWG)\tcopper ampacity (amps)\n";
std::cout<<"---------------------------------------\n";
std::cout <<"14\t\t15\n";
std::cout <<"12\t\t20\n";
std::cout <<"10\t\t30\n";
std::cout <<"8\t\t45\n";
std::cout <<"6\t\t65\n";
return 0;
}

Output :

Exercise 3.

Aim : Write a program that calculates and


displays the total resistance of a series and

parallel circuit.

Program :
#include<iostream>
using namespace std;
int main(){
int R1 , R2 , R3;
int totalresistance;
char circuitType;
cout << "enter resistance R1 (in ohm): ";
cin >> R1;
cout << "enter resistance R2 (in ohm): ";
cin >> R2;
cout << "enter resistance R3 (in ohm): ";
cin >> R3;
cout << "enter the type of circuit ('S' for series, 'p' for parallel): ";
cin>>circuitType;
if (circuitType == 'S' || circuitType == 's') {
totalresistance = R1 + R2 + R3;
cout << "the total resistance of the series circuit is :" << totalresistance <<
"ohms" <<endl;
}else if (circuitType == 'P' || circuitType == 'p') {
totalresistance = 1.0/ ((1.0/R1 + 1.0/R2 + 1.0/R3));
cout << "total resistance of the parallel circuit is: " <<totalresistance<<
"ohms "<< endl;
} else {
cout << "invalid circuit type entered. please enter 'S' for series or 'P' for
parallel." << endl;
}
return 0;
}

Output :

Exercise 4.

Aim : Write a program to calculate voltage


across a resistor using Ohm’s law.

Program :
#include<iostream>
using namespace std;
int main(){
float Resistance,Current,Voltage;
cout<<"Enter the resistance in ohms: ";
cin>>Resistance;
cout<<"Enter the current in amperes: ";
cin>>Current;
Voltage=Resistance*Current;
cout<<"The voltage is: "<<Voltage<<" volts";
return 0;
}

Output :

Exercise 5.

Aim :Write a program for calculating power in


an electrical circuit.

Program :
#include<iostream>
using namespace std;
int main(){
float Current,Resistance,Power;
cout<<"Enter the current in amperes: ";
cin>>Current;
cout<<"Enter the resistance in ohms: ";
cin>>Resistance;
Power=Current*Current*Resistance;
cout<<"The power is: "<<Power<<"watts"<<endl;
return 0;
}

Output :

Exercise 6.
Aim :Write a program to calculate RMS (Root
Mean Square) voltage from peak voltage using

the square root function (sqrt).

Program :
#include <iostream>
using namespace std;
int main() {
float V_peak;
cout << "Enter the peak voltage (in volts): ";
cin >> V_peak;
float V_RMS = V_peak / sqrt(2);
cout << "The RMS voltage is: " << V_RMS << " volts" << endl;
return 0;
}

Output :

Exercise 7.

Aim : Write a program to calculate the


frequency of an RC circuit.

Program :
#include <iostream>
using namespace std;
int main() {
float R, C, frequency;
const float PI=3.14;
cout << "Enter the resistance (in ohms): ";
cin >> R;
cout << "Enter the capacitance (in farads): ";
cin >> C;
frequency = 1.0 / (2*PI*R*C);
cout << "The frequency of the RC circuit is: " << frequency << " Hz" << endl;
return 0;
}

Output :

Exercise 8.

Aim : Write a program to calculate the


resonant frequency of an LC circuit (inductor-

capacitor circuit).

Program :
#include <iostream>
using namespace std;
int main() {
float L, C, frequency;
const float PI=3.14;
cout << "Enter the inductance (in henries): ";
cin >> L;
cout << "Enter the capacitance (in farads): ";
cin >> C;
frequency = 1 / (2*PI*sqrt(L * C));
cout << "The resonant frequency of the LC circuit is: " << frequency << " Hz" <<
endl;
return 0;
}

Output :
Exercise 9.

Aim : Write a program to calculate the


frequency of an AC voltage signal.

Program :
#include <iostream>
using namespace std;
int main() {
float omega, frequency;
const float PI=3.14;
cout << "Enter the angular frequency (in radians per second): ";
cin >> omega;
frequency = omega / (2 * PI);
cout << "The frequency of the AC voltage signal is: " << frequency << " Hz" <<
endl;
return 0;
}

Output :

Exercise 10.

Aim : Write a program to calculate the


voltage across an inductor based on its

inductance and the rate of change of current.


Program :
#include <iostream>
#include<cmath>
using namespace std;
int main() {
float inductance, rateOfChangeOfCurrent,Voltage;
cout << "Enter the inductance (L) in henries: ";
cin >> inductance;
cout << "Enter the rate of change of current (dI/dt) in amperes per second: ";
cin >> rateOfChangeOfCurrent;
Voltage = rateOfChangeOfCurrent*inductance;
cout<<"The voltage across the inductor is: " << Voltage << " volts." << endl;
return 0;
}

Output :

Exercise 11.

Aim :Write a program to calculate the roots


of a quadratic equation using decision control

statements in perspective to work with the all

the cases whether the equation gives a real,

imaginary or equal

Program :
#include<iostream>
using namespace std;
int main(){
float a,b,c,d;
d=((b*b)-4*a*c);
cout<<"enter the value of (a):";
cin>>a;
cout<<"enter the value of (b):";
cin>>b;
cout<<"enter the value of (c):";
cin>>c;
if (d>0){
cout<<"the roots are real and distinct";
}else if (d==0){
cout<<"the roots are equal";
}else {
cout<<"the roots are imaginary";
}
return 0;
}

Output :

Exercise 12.

Aim :Simulate the control of an LED (ON/OFF)


using if-else statements.

Program :
OUTPUT-

Exercise 13.

AIM : WRITE A PROGRAM TO SIMULATE THE CHARGING PROCESS OF A


CAPACITOR AND USES AN IF STATEMENT TO CHECK WHETHER THE
CAPACITOR IS FULLY CHARGED OR STILL CHARGING BASED ON THE
CALCULATED VOLTAGE.
Program :

OUTPUT-
Exercise 15.

AIM :WRITE A PROGRAM USING A SWITCH STATEMENT TO CONTROL


THE DIRECTION OF A MOTOR BASED ON THE USER'S INPUT.

Program :
OUTPUT-

Exercise 14.

Aim :.Write a program which uses cascading if and else if


statements to determine the warning level based on the entered

temperature.

Program :

Output :

Exercise 16.

Aim : Write a program using a switch statement to control a


voltage regulator based on a control signal.
Program:

Output :

Exercise 17.
Aim :Write a program using cascading if and else if statements
to determine the speed level of a motor based on RPM

Program :
Output :

Exercise 18.

Aim : Write a program for Metric Conversions of Various


Properties: Temperature, Length, Energy and Power using switch

statement.
Program :
OUTPUT-

Exercise 19.

Aim :Write program showcases the use of iterative statements


(for loop), to create a basic circuit analysis tool.

Program :
OUTPUT-

Exercise 20.

Aim :Given a resistor with a constant resistance, calculate the


voltage across the resistor for a range of currents

Program :
OUTPUT-

Exercise 21.

Aim : Write a program to calculate the charging of a capacitor

in an RC circuit at different time intervals of 10 milliseconds.

Program :
OUTPUT-
Exercise 22.

Aim : Write a program for voltage across the capacitor at any

given time can be calculated using the formula:

V(t)=Vmax × (1-e-t/RC)

Program :
OUTPUT-

Exercise 23.

Aim :Create a C++ program to store and manipulate an array of


voltages in a circuit. The program should calculate the total,

average, minimum and maximum voltage values using 1D arrays,

allowing for effective analysis and management of voltage data

within the circuit.

Program :
OUTPUT-

Exercise 24.

Aim :Calculate Total Resistance of Resistors in Series Using


Dynamic Memory Allocation

Program :
OUTPUT-

Exercise 25.

Aim :Calculate Power Dissipated by a Resistor Using Call by


Reference

Program :
OUTPUT-

Exercise 26.

Aim :Write a C++ program that accepts a string input


representing the type of circuit (e.g., "Series", "Parallel") and

calculate total resistance.

Program :
OUTPUT-

Exercise 27.

Aim :Write a C++ program to convert lowercase letters to


uppercase letters in a given input string.

Program :
OUTPUT-

Exercise 28.

Aim : Write a C++ program to create a file that stores the


resistance, current, and voltage values of a circuit.

Program :
OUTPUT-

You might also like