4 views

Uploaded by venu

cs lab important

- Trigonometry Formulae
- Cbse Sample Papers for Class 11 Maths Download PDF
- [Edu.joshuatly.com] Kedah SPM Trial 2011 Maths T (w Ans)
- mathemat_ext2_01.pdf
- Top 20 c Programa Asked in Interviwes
- 9709_y06_sy.pdf
- ex
- Topic 1_ Investigating features of trigonometric graphs
- Program
- Com Trade Relay
- midyear 12-13
- 1.Write a Program to Implement Lexical Analyzer_1486565343567_1486746461211
- Assignment 2.docx
- Assignment 1
- Outputs
- ign-c prog
- Soal Trigonometri - Copy Backup
- processing-3.1-windows64.txt
- 478fgf
- MA011 1209 eqp

You are on page 1of 5

CS110-Lab 8

1.

Write a C Program to write sin(x) , cos(x) and tan(x) to a data file. Sample program is

shown in appendix (plot the data using Excel). Also plot a random number graph (use

rand()).

5 ( points)

2. Write your own functions for my_sin(x), my_cos(x),and my_exp using Taylor series

expansion . Test the functions appropriate test cases and compare with built in

functions. ( A sample sinx function is given in appendix)

10 ( points)

3.

Develop, and implement C program that reads N integer numbers and arrange them in

ascending order using one of the sorting techniques. Write the numbers to a file.

10 ( points)

4.

by: P(h)= k*exp(-0.12*h); where pressure P is in units of millibars (gm/cm^2), and

height h is in kilometers. The formula applies to heights less than about 80 km. . Write a

program that prints a table of pressures from sea level to 80 km in l0km steps for

different values of k ranging from 1000 to 1050. Plot the graph using Excel.

10 ( points)

5. Although C includes the hyperbolic functions among its intrinsic functions, it doesn't

include the inverse hyperbolic functions

sinh-1(x) = In[x + (x^2 + 1) 1/2]

cosh-1 (x) = In[x + (x^2 - 1)1/2]

tanh-1 (x) = In[(l + x)/(l - x)]/2

Write a program that displays the hyperbolic functions and their inverses, using our own

functions for the inverse functions.

10 ( points)

6. A sample program for calculating execution time is shown in appendix . By

appropriately modifying the above programs find their execution time. (optional:

Compare execution time using different Compilers)

5 ( points)

40 points for the program and demo ( as listed above) and 10 points report. Report should

contain the algorithm either in flow chart or in steps and the source code. Submit a single

document file (either in pdf or word). Report submission deadline is Monday 11.59 PM.

Submission.

Where to submit?

Email to : cs110.iitp@gmail.com

(use email subject as L8_your roll number ).

#include <stdio.h>

#include <math.h>

double Pressure(double height);

int main()

{

float height;

FILE *fp1;

float pi;

pi=(float) 22/7;

printf("Ploting functions\n");

printf(" sin(x)\n");

printf("-----------------\n");

fp1 = fopen("plot2.dat","w");

for(height=0; height<=2*pi; height+=.1){

fprintf(fp1,"%f

%f\n",height, sin(height));

printf("%f %f\n",height, sin(height));

}

printf("closing data files\n");

fclose(fp1);

return 0;

}

My_sinx function

double my_sinx( int ang_deg, int no_of_terms )

{

int term, j;

double value = 0.0, ang_rad = 0.0;

ang_rad = ( double ) ang_deg * PI / 180;

for ( term = 1, j = 2;term < no_of_terms*2;term += 2, j++ )

{

value += ( double ) pow( -1.0, j ) * pow( ang_rad, term ) / fact( term );

}

return value;

}

int fact( int num )

{

int f = 0;

if ( num == 1 )

return 1;

else

f = num * fact( num - 1 );

return f;

}

#include <stdio.h>

#include <math.h>

double Pressure(double height);

int main()

{

int height;

FILE *fp1;

printf("height pressure\n");

printf(" k in gm/cm'2\n");

printf("-----------------\n");

fp1 = fopen("plot11.dat","w");

for(height=0; height<=80; height+=1){

fprintf(fp1,"%d

%f\n",height,Pressure(height));

printf("%d %f\n",height,Pressure(height));

}

printf("closing data files\n");

fclose(fp1);

return 0;

}

pressure, gm/cm2

{

return 1035*exp(-0.12*height);

}

Execution Timing

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#define CSEC (double)(CLOCKS_PER_SEC)

int main(void)

{

clock_t c1, c2;

int i, j;

c1 = clock();

for(i=0; i<100000000; i++)

j = i * 2;

c2 = clock();

printf("%f\n", (double)(c2-c1)/CSEC);

return 0;

}

- Trigonometry FormulaeUploaded byabc
- Cbse Sample Papers for Class 11 Maths Download PDFUploaded bycafinal
- [Edu.joshuatly.com] Kedah SPM Trial 2011 Maths T (w Ans)Uploaded byWindy Wayne
- mathemat_ext2_01.pdfUploaded byYe Zhang
- Top 20 c Programa Asked in InterviwesUploaded bySuraj Singh
- 9709_y06_sy.pdfUploaded byAhmet Arduç
- exUploaded byShaker Mahmood
- Topic 1_ Investigating features of trigonometric graphsUploaded bynik1506
- ProgramUploaded byVibhor Barnwal
- Com Trade RelayUploaded bymourinho22
- midyear 12-13Uploaded byapi-253679034
- 1.Write a Program to Implement Lexical Analyzer_1486565343567_1486746461211Uploaded byanon_237947746
- Assignment 2.docxUploaded byChris
- Assignment 1Uploaded byvikram_tatineni
- OutputsUploaded byMohammed Thawfeeq
- ign-c progUploaded bySandip Paul
- Soal Trigonometri - Copy BackupUploaded byTeguh Wiryanto
- processing-3.1-windows64.txtUploaded byAnonymous 41Zlge
- 478fgfUploaded byEshwarPrasad
- MA011 1209 eqpUploaded byVeiliLook
- math 10600001Uploaded byapi-243047025
- eighth grade key learningsUploaded byapi-344851377
- 0606_s13_ms_11Uploaded bySherlock Wesley Conan
- Calc Notes 0103Uploaded byNjoka Samuel K
- LAB 1_amritUploaded byamrit kumar das
- Curriculum Review New Hl and Sl April 2017Uploaded byTang Kin On
- BScCSIT-2Uploaded bystealthhacker
- PRECALCULOUploaded byLeonardo Torres
- 401Spring14M1 SolutionsUploaded byLevis
- Mathematics and StatisticsUploaded byRashmi Manjrekar

- IES ME.pdfUploaded byswapnil
- Sucessful PaymentUploaded byvenu
- ME292 Group 3Uploaded byvenu
- ReminderUploaded byvenu
- ESE_2017_English_Notice_256.pdfUploaded byAjeet Verma
- Baja Teams (1)Uploaded byvenu
- 6thsemprojectreport-170228151416Uploaded byvenu
- Btech TT 2 3 4 Years Final-4Uploaded byvenu
- KundanUploaded byvenu
- Time TableUploaded byvenu
- Nano allUploaded byvenu
- chittaranjanlocomotiveworks-131129105840-phpapp01Uploaded byvenu
- Time TableUploaded byvenu
- chap8eUploaded byvenu
- 18-L3-00199 (2)Uploaded byvenu
- LSD Quotation 2Uploaded byvenu
- Lecture 20 DefectsUploaded byvenu
- Lecture 22 Plastic DeformationUploaded byvenu
- Lecture 21 Mechanical PropertiesUploaded byvenu
- Language of the MEDIAUploaded byvenu
- Voids in crystals.pdfUploaded byvenu
- Voids in crystals.pdfUploaded byvenu
- Btech TT 2 3 4 Years Final-4Uploaded byvenu
- ForcesUploaded byvenu
- 2Continuty.PDFUploaded byvenu
- Statics 6th Edition Meriam Kraige Solution ManualUploaded byJose Romero
- Analyticity.pdfUploaded byvenu
- Suspension 12Uploaded byvenu
- rfdfgtb.txtUploaded byvenu
- supra_rule_book__2015.pdfUploaded byvenu

- What is ActimelUploaded byTanja_Sporrer_6559
- Rotatory Motion -3Uploaded byShiva Ram Prasad Pulagam
- The Business Background of Alcon EnterprisesUploaded byIvan Bendiola
- Food and Beverage CourseUploaded bytomzayco
- Malaysian Economy SystemUploaded byKassthurei Yogarajan
- FELCOM 15 OMEUploaded bycristianocalheiros
- magmapUploaded byJemmy Haryanto
- D5200 ManualUploaded byManas George
- Calculator Skills Worksheet - Sp Sharp531Uploaded byGeoffrey Dix
- Registration of Partnership Firm in MaharashtraUploaded byAdv. Govind S. Tehare
- Inhibitors.pdfUploaded byandrea
- Rbl CatalogueUploaded byVenkatesh V
- Marketing and Export of Citrus FruitUploaded byashhhhhhhh
- Brazil VisaUploaded bySa3ma4na
- Modeling FRP and Plastic Piping in AutoPIPEUploaded byRicky Luzny
- 1336Uploaded bydshemanthkumar
- In Stg Training Catalogue 2010Uploaded byloveanit
- Footprints - Memoirs of an Indian PatriarchUploaded bybooksarabia
- Capital Budgeting NotesUploaded bywgl.joshi
- 1 THE INFLUENCE OF CAPITAL STRUCTURE ON FIRMS’ PERFORMANCE: A CASE OF SELECTED FIRMS’ LISTED IN NAIROBI SECURITIES EXCHANGE ,KENYAUploaded bycuteeangel1
- Cliping Triangular MeshUploaded byapoorvs75
- 1602 cynefin framework aoh companionUploaded byapi-335788498
- adc0831-nUploaded byToni Biosca
- r5410202 Power Semiconductor DrivesUploaded bysivabharathamurthy
- Ginkgo BilobaUploaded byLaurentiu M.
- Computer Numerical Control Ip 710Uploaded byvajram1
- Excise Duty PptUploaded bypednekar30
- Linear Sweep and Cyclic Voltametry_ the Principles — Department of Chemical Engineering and BiotechnologyUploaded byDhanika Senaviratne
- Nice Folder Sliding EnUploaded bysateesh_chandra_1
- Engineering Design Guideline Static Mixer Rev02webUploaded byWilfredo Suarez Torres