


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



-^ if^ (i^ <^ 2) โ^ if^ (i^ <=^ 2) โ^ if^ (i^ >=^ -1) โ^ if^ (i^ ==^ 4)^
//^ note^ difference
between^ ==^ and^ =
-^ if^ (x^ ==^ 1.0) โ^ if^ (fabs(x)^ <^ 10.0) โ^ if^ (i^ <^8 &&^ i^
&&^ =^ and
-^ if^ (x^ >^ 10.0^ ||
x^ <^ -10.0)^ //
||^ =^ or
#include^ <stdio.h>#include^ <math.h>double^ gauss(double
x,^ double^ amplitude,
double^ center,^ double
sigma);
int^ main(){double^ gaussval1,gaussval2;double^ xval=-1.4,ampl=100.0,ctr=0.1,sig=2.0;gaussval1^ =^ gauss(1.5,10.0,0.0,2.0);gaussval2^ =^ gauss(xval,ampl,ctr,sig);printf("Gaussval
=^ %f;^ Gaussval^
=^ %f\n",gaussval1,gaussval2); return^ 0;} double^ gauss(double
x_val,^ double^ amplitude,
double^ center,^ double
sigma)
{return^ amplitudeexp(-0.5pow((x_val-center)/sigma,2));}
-^ not^ strictly^ necessary,
-^ we^ can^ pass^ either
-^ names^ donโt^ have
-^ can^ pass^ any^ number
-^ limited^ to^ a^ single
-^ but^ the^ program
-^ character^ arrays
-^ strings^ must^ end
-^ must^ allow^ room:
int^ i[8],^ j[8]={0},
k[]={9,8,6,5,4,3,2,1,0}; double^ x[10],^ y[10000]={0.0},
z[2]={1.0,3.0}; char^ name[20],^ state[]=โCaliforniaโ;
-^ #include <string.h>
int^ i,j[8]={0},k[]={2,4,6,8,1,3,5,7};double^ x[8]={0.0},y[2]={1.0,3.0},z[8];char^ name[20],state[]="California";for^ (i=0;^ i<8;^ i++){z[i]^ =^ 0.0;printf(โj[%d]^ =
%d,^ k[%d]^ =^ %d\n",i,j[i],i,k[i]); }name[0]='T';name[1]='o';name[2]='m';name[3]^ =^ '\0';printf("%s^ starts
with^ %c^ and^ lives
in^ %s\n",name,name[0],state);
-^ empty^ spaces^ at
-^ indexing^ int[8]
-^ #define^ comes
-^ Convention^ to^ use^ all
double^ b[],^ double
c[]); int^ main(){double^ a[]={1.0,
double^ b[]={1.0,^
double^ c[9];mm3x3(a,b,c);printf("c^ =^ %f^ %f
%f\n",c[0],c[1],c[2]); printf("^ %f^ %f
%f\n",c[3],c[4],c[5]); printf("^ %f^ %f
%f\n",c[6],c[7],c[8]); return^ 0;}
double^ a[3][3]={{1.0,
double^ b[3][3]={{1.0,
double^ c[3][3];mm3x3(a,b,c);