Devdutt Shenoi 16 July 2016

Building a C++ Application to cheat the readings

Program files

There are actually two files in this Set. The first of these programs is 'find.cpp'. find was built as a program to calculate the length of A.C. Sonometer wire which gives the correct reading, which we are looking for.

Header files

#include <iostream>
#include <math.h>
Set namespace
using namespace std;

Define functions

calc():

This is a function which will solve this equation( Equation for AC Sonometer ) with the variables provided.

float calc(float t,float u,float l){
	return sqrt(t)/(2*l*sqrt(u));
}
ten():

This function will multiply the value of weight by the constant of acelleration due to gravity.

float ten(float x){
  return x*0.0098;
}
com():

This function returns the mean of the two length input.

float com(float x1, float x2){
  return(x1+x2)/200;
}
main():

Here this function will run through at the beginning and end of the program.

int main()
{
	int w;
	float n,t,u,l1,l2,l;
	cout<<"Calculate Frequency of AC from lengths on Sonometer!!\n";
	cout<<"What are the lengths?(cm)\nl.1:";
	cin>>l1;
	cout<<"l.2:";
	cin>>l2;
	l=com(l1,l2);
	cout<<"Mean length = "<< l <<" What is the value of weights(g)? ";
	cin>>w;
	t= ten(w);
	cout<<"Tension = "<< t;
	cout<<" Kgm/s\nWhat is the value of linear density of wire U(g/m)?\n";
	cin>>u;
	n=calc(t,u,l);
	cout<<"\nTherefore frequency of AC is "<< n <<" Hz\n";
	return 0;
}
Download source code from: