├── Class Slides ├── C Programming day 3.pdf ├── C Programming day 4.pdf ├── nov 20.pdf └── nov19.pdf ├── November 17 source code Pendulum ├── moveConstantangularVelocity │ └── moveConstantangularVelocity.pde ├── moveSHM │ └── moveSHM.pde ├── simplePendulumDemoFinal │ └── simplePendulumDemoFinal.pde ├── simplePendulumDemoWithoutDamping │ └── simplePendulumDemoWithoutDamping.pde ├── simplePendulumDemoWithoutSHM │ └── simplePendulumDemoWithoutSHM.pde └── source code.pdf ├── Processing Sketches Advanced └── islamic_geometric_design │ ├── Edge.pde │ ├── Polygon.pde │ └── islamic_geometric_design.pde ├── Processing sketches examples from class ├── clock │ ├── clock │ │ └── clock.pde │ ├── clock_II │ │ └── clock_II.pde │ ├── clock_III │ │ └── clock_III.pde │ ├── clock_IV │ │ └── clock_IV.pde │ └── clock_V │ │ └── clock_V.pde ├── sketch_171113a_multiplebounce.pde ├── sketch_171113e_singleBallRandom │ └── sketch_171113e_singleBallRandom.pde └── sketch_171113e_singleBallSimple │ └── sketch_171113e_singleBallSimple.pde ├── printBill.c └── testfile.txt /Class Slides/C Programming day 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msrepo/cprogramming2018/508d494af308ef887611b895fe600ee9bc1264eb/Class Slides/C Programming day 3.pdf -------------------------------------------------------------------------------- /Class Slides/C Programming day 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msrepo/cprogramming2018/508d494af308ef887611b895fe600ee9bc1264eb/Class Slides/C Programming day 4.pdf -------------------------------------------------------------------------------- /Class Slides/nov 20.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msrepo/cprogramming2018/508d494af308ef887611b895fe600ee9bc1264eb/Class Slides/nov 20.pdf -------------------------------------------------------------------------------- /Class Slides/nov19.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msrepo/cprogramming2018/508d494af308ef887611b895fe600ee9bc1264eb/Class Slides/nov19.pdf -------------------------------------------------------------------------------- /November 17 source code Pendulum/moveConstantangularVelocity/moveConstantangularVelocity.pde: -------------------------------------------------------------------------------- 1 | int diameter = 50; 2 | float x,y; 3 | float amplitude = 100,theta; 4 | float endX,endY; 5 | void setup(){ 6 | 7 | size(800,600); 8 | 9 | x = 0; y = 100 + diameter/2; 10 | endX =0; endY = 100; 11 | frameRate(2); 12 | } 13 | 14 | 15 | void draw(){ 16 | //background(150); 17 | theta +=0.05; 18 | endX = amplitude * cos(theta); 19 | endY = amplitude * sin(theta); 20 | x = (amplitude + diameter/2) * cos(theta); 21 | y = (amplitude + diameter/2) * sin(theta); 22 | translate(width/2,height/2); 23 | line(0,0,endX,endY); 24 | ellipse(x,y,diameter,diameter); 25 | 26 | } -------------------------------------------------------------------------------- /November 17 source code Pendulum/moveSHM/moveSHM.pde: -------------------------------------------------------------------------------- 1 | int diameter = 50; 2 | float x,y; 3 | float amplitude = 100,theta; 4 | float damping = 0.99; 5 | float endX,endY; 6 | float angularVelocity,angularAcceleration; 7 | void setup(){ 8 | 9 | size(800,600); 10 | angularAcceleration = 0.03; 11 | angularVelocity = 0; 12 | x = 0; y = 100 + diameter/2; 13 | endX =0; endY = 100; 14 | //frameRate(2); 15 | } 16 | 17 | 18 | void draw(){ 19 | background(150); 20 | angularVelocity += angularAcceleration; 21 | theta +=angularVelocity; 22 | angularVelocity *= damping; 23 | angularAcceleration = 0.01 * cos(theta) * damping; 24 | endX = amplitude * cos(theta); 25 | endY = amplitude * sin(theta); 26 | x = (amplitude + diameter/2) * cos(theta); 27 | y = (amplitude + diameter/2) * sin(theta); 28 | translate(width/2,height/2); 29 | line(0,0,endX,endY); 30 | ellipse(x,y,diameter,diameter); 31 | 32 | } -------------------------------------------------------------------------------- /November 17 source code Pendulum/simplePendulumDemoFinal/simplePendulumDemoFinal.pde: -------------------------------------------------------------------------------- 1 | float rodX, rodY; 2 | float damping =0.99; 3 | int diameter = 50; 4 | float ellipseX, ellipseY; 5 | float theta; 6 | int amplitude = 100; 7 | float angularVelocity, angularAcceleration; 8 | void setup() { 9 | rodX = 0; 10 | rodY = amplitude; 11 | ellipseX = 0; 12 | ellipseY = rodY+diameter/2; 13 | theta = 0; 14 | angularVelocity =0; 15 | size(800, 600); 16 | background(150); 17 | //frameRate(2); 18 | } 19 | 20 | void draw() { 21 | background(150); 22 | angularAcceleration = -0.01 * sin(theta-PI/2) * damping; 23 | angularVelocity +=angularAcceleration; 24 | angularVelocity *=damping; 25 | theta +=angularVelocity; 26 | rodX = amplitude *cos(theta); 27 | rodY = amplitude *sin(theta) ; 28 | ellipseX = (amplitude + diameter/2)*cos(theta); 29 | ellipseY = (amplitude + diameter/2)*sin(theta); 30 | translate(width/2, height/2); 31 | line(0, 0, rodX, rodY); 32 | ellipse(ellipseX, ellipseY, diameter, diameter); 33 | } -------------------------------------------------------------------------------- /November 17 source code Pendulum/simplePendulumDemoWithoutDamping/simplePendulumDemoWithoutDamping.pde: -------------------------------------------------------------------------------- 1 | float rodX, rodY; 2 | float damping =1; 3 | int diameter = 50; 4 | float ellipseX, ellipseY; 5 | float theta; 6 | int amplitude = 100; 7 | float angularVelocity, angularAcceleration; 8 | void setup() { 9 | rodX = 0; 10 | rodY = amplitude; 11 | ellipseX = 0; 12 | ellipseY = rodY+diameter/2; 13 | theta = 0; 14 | angularVelocity =0; 15 | size(800, 600); 16 | background(150); 17 | //frameRate(2); 18 | } 19 | 20 | void draw() { 21 | background(150); 22 | angularAcceleration = -0.01 * sin(theta-PI/2) * damping; 23 | angularVelocity +=angularAcceleration; 24 | angularVelocity *=damping; 25 | theta +=angularVelocity; 26 | rodX = amplitude *cos(theta); 27 | rodY = amplitude *sin(theta) ; 28 | ellipseX = (amplitude + diameter/2)*cos(theta); 29 | ellipseY = (amplitude + diameter/2)*sin(theta); 30 | translate(width/2, height/2); 31 | line(0, 0, rodX, rodY); 32 | ellipse(ellipseX, ellipseY, diameter, diameter); 33 | } -------------------------------------------------------------------------------- /November 17 source code Pendulum/simplePendulumDemoWithoutSHM/simplePendulumDemoWithoutSHM.pde: -------------------------------------------------------------------------------- 1 | float rodX, rodY; 2 | float damping =1; 3 | int diameter = 50; 4 | float ellipseX, ellipseY; 5 | float theta; 6 | int amplitude = 100; 7 | float angularVelocity, angularAcceleration; 8 | float aVel; 9 | void setup() { 10 | rodX = 0; 11 | rodY = amplitude; 12 | ellipseX = 0; 13 | ellipseY = rodY+diameter/2; 14 | theta = 0; 15 | angularVelocity =0; 16 | aVel = 0.03; 17 | size(800, 600); 18 | background(150); 19 | //frameRate(2); 20 | } 21 | 22 | void draw() { 23 | background(150); 24 | angularAcceleration = -0.01 * sin(theta-PI/2) ; 25 | angularVelocity +=angularAcceleration; 26 | //angularVelocity *=damping; 27 | theta +=angularVelocity; 28 | theta +=aVel; 29 | if(theta >= PI || theta <= 0) aVel = -aVel; 30 | rodX = amplitude *cos(theta); 31 | rodY = amplitude *sin(theta) ; 32 | ellipseX = (amplitude + diameter/2)*cos(theta); 33 | ellipseY = (amplitude + diameter/2)*sin(theta); 34 | translate(width/2, height/2); 35 | line(0, 0, rodX, rodY); 36 | ellipse(ellipseX, ellipseY, diameter, diameter); 37 | } -------------------------------------------------------------------------------- /November 17 source code Pendulum/source code.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msrepo/cprogramming2018/508d494af308ef887611b895fe600ee9bc1264eb/November 17 source code Pendulum/source code.pdf -------------------------------------------------------------------------------- /Processing Sketches Advanced/islamic_geometric_design/Edge.pde: -------------------------------------------------------------------------------- 1 | 2 | class Edge{ 3 | PVector a,b; 4 | 5 | Edge(float xa_,float ya_, float xb_, float yb_){ 6 | a.x = xa_; a.y = ya_; b.x = xb_; b.y = yb_; 7 | } 8 | 9 | void show(){ 10 | beginShape() ; 11 | vertex(a.x,a.y); 12 | vertex(b.x,b.y); 13 | endShape(); 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /Processing Sketches Advanced/islamic_geometric_design/Polygon.pde: -------------------------------------------------------------------------------- 1 | class Polygon { //<>// 2 | final int VMAX = 10; 3 | float angle; 4 | PVector[] vertices; 5 | int vsize, esize; 6 | Polygon() { 7 | vsize = esize = 0; 8 | vertices = new PVector[VMAX]; 9 | } 10 | 11 | void setAngle(float angle_){ 12 | angle = angle_; 13 | } 14 | 15 | void addVertex(int x, int y) { 16 | PVector v = new PVector(x, y); 17 | if ( vsize < VMAX) { 18 | vertices[vsize++] = v; 19 | } 20 | } 21 | 22 | void show() { 23 | beginShape(); 24 | for (int i = 0; i < vsize; i++) 25 | vertex(vertices[i].x, vertices[i].y); 26 | endShape(CLOSE); 27 | } 28 | 29 | void hankin() { 30 | for (int i = 0; i width) xspeed[i] = -xspeed[i]; 43 | if (y[i] > height) yspeed[i] = -yspeed[i]; 44 | if (x[i] < 0 && xspeed[i] < 0) xspeed[i] = -xspeed[i]; 45 | if (y[i] < 0 && yspeed[i] < 0) yspeed[i] = -yspeed[i]; 46 | 47 | 48 | x[i]+=xspeed[i]; 49 | y[i]+=yspeed[i]; 50 | 51 | //x *=0.95; 52 | //y *=0.95; 53 | 54 | fill(255); 55 | ellipse(x[i], y[i], ellipsewidth, ellipseheight); 56 | } 57 | } -------------------------------------------------------------------------------- /Processing sketches examples from class/sketch_171113e_singleBallRandom/sketch_171113e_singleBallRandom.pde: -------------------------------------------------------------------------------- 1 | 2 | int ellipsewidth; 3 | int ellipseheight; //declare 4 | float x, y; 5 | float xspeed,yspeed; 6 | void setup() { 7 | ellipseheight = 50; //initialize 8 | ellipsewidth = 50; 9 | 10 | x = 300; 11 | y = 200; 12 | xspeed = 7; 13 | yspeed = 7; 14 | size(600, 400); 15 | } 16 | 17 | 18 | void draw() { 19 | //fill(0,25); 20 | //rect(0,0,width,height); 21 | // if x gets upto 600, then go back to 300 22 | 23 | background(0); 24 | xspeed += random(-5,5); 25 | yspeed += random(-5,5); 26 | 27 | xspeed *= 0.96; 28 | yspeed *= 0.96; 29 | x = x + xspeed;// x <- x + 5 30 | y += yspeed;//y = y + yspeed 31 | if( x > width || x < 0) xspeed = -xspeed; 32 | //if( x < 0) xspeed = -xspeed; 33 | if( y > height || y < 0) yspeed *= -1.0; // yspeed = yspeed * -1; 34 | 35 | 36 | //y = y + 1; 37 | fill(255); 38 | ellipse(x, y, ellipsewidth, ellipseheight); 39 | //ellipse(x + 50,y + 50, ellipsewidth,ellipseheight); 40 | } -------------------------------------------------------------------------------- /Processing sketches examples from class/sketch_171113e_singleBallSimple/sketch_171113e_singleBallSimple.pde: -------------------------------------------------------------------------------- 1 | 2 | int ellipsewidth; 3 | int ellipseheight; //declare 4 | float x, y; 5 | float xspeed,yspeed; 6 | void setup() { 7 | ellipseheight = 50; //initialize 8 | ellipsewidth = 50; 9 | 10 | x = 300; 11 | y = 200; 12 | xspeed = 7; 13 | yspeed = 7; 14 | size(600, 400); 15 | } 16 | 17 | 18 | void draw() { 19 | //fill(0,25); 20 | //rect(0,0,width,height); 21 | // if x gets upto 600, then go back to 300 22 | 23 | background(0); 24 | 25 | 26 | 27 | x = x + xspeed;// x <- x + 5 28 | y += yspeed;//y = y + yspeed 29 | if( x > width || x < 0) xspeed = -xspeed; 30 | //if( x < 0) xspeed = -xspeed; 31 | if( y > height || y < 0) yspeed *= -1.0; // yspeed = yspeed * -1; 32 | 33 | 34 | //y = y + 1; 35 | fill(255); 36 | ellipse(x, y, ellipsewidth, ellipseheight); 37 | //ellipse(x + 50,y + 50, ellipsewidth,ellipseheight); 38 | } -------------------------------------------------------------------------------- /printBill.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | char temptext[80]; 5 | 6 | void centerJustifyPrint(int width, char * text){ 7 | int textLength = strlen(text); 8 | printf("%*s", (width - textLength)/2,""); 9 | printf("%*s",textLength,text ); 10 | printf("%*s", (width - textLength)/2,""); 11 | } 12 | void centerJustifyPrinti(int width, int text){ 13 | 14 | sprintf(temptext,"%d",text); 15 | centerJustifyPrint(width,temptext); 16 | } 17 | void fillWithDash(int width){ 18 | int i; 19 | for(i = 1; i<=width;i++) 20 | printf("-"); 21 | } 22 | void printAndfillWithDash(int width,char * text){ 23 | printf("%-*s",strlen(text),text); 24 | fillWithDash(width-strlen(text)); 25 | } 26 | void fillWithDots(int width, char * text){ 27 | if(width <0){ 28 | width=-width; 29 | printf("%-*s",strlen(text),text ); 30 | int i; 31 | for(i=1;i<=width-strlen(text);i++) 32 | printf("." ); 33 | }else{ 34 | int i; 35 | 36 | for(i=1;i<=width-strlen(text);i++) 37 | printf("." ); 38 | printf("%-*s",strlen(text),text ); 39 | } 40 | } 41 | void printLetterHead(){ 42 | 43 | printf("%-40s","Seller's PAN No. 86"); 44 | printf("%40s","061-463697"); 45 | 46 | printf("\n"); 47 | 48 | printf("%-40s","Buyer's PAN No.: "); 49 | printf("%40s","061-463203"); 50 | 51 | printf("\n"); 52 | 53 | printf("%28s","" ); 54 | printf("%s","NEPAL MANDALA BOOK SHOP" ); 55 | printf("%28s","" ); 56 | 57 | printf("\n"); 58 | 59 | printf("%20s","" ); 60 | centerJustifyPrint(40,"Lakeside,Pokhara"); 61 | printf("%20s","PAN:300452057" ); 62 | 63 | printf("\n"); 64 | 65 | printf("%80s","Date :........." ); 66 | 67 | printf("\n"); 68 | 69 | printf("%-80s","Bill No.:" ); 70 | printf("\n"); 71 | 72 | // printf("%-80s","M/S" ); 73 | fillWithDots(-80,"M/S"); 74 | printf("\n"); 75 | } 76 | 77 | void printTableHeader(){ 78 | fillWithDash(80); 79 | printf("\n"); 80 | centerJustifyPrint(5,"S.N."); 81 | centerJustifyPrint(40,"Description"); 82 | centerJustifyPrint(5,"Qty."); 83 | centerJustifyPrint(10,"Rate"); 84 | centerJustifyPrint(10,"Discount"); 85 | centerJustifyPrint(10,"Total"); 86 | printf("\n"); 87 | fillWithDash(80); 88 | printf("\n"); 89 | } 90 | 91 | void printRow(char * bookname, int qty, int rate, int discount){ 92 | static int i=1; 93 | printf("%-5i",i ); 94 | printf("%-40s",bookname ); 95 | centerJustifyPrinti(5,qty); 96 | centerJustifyPrinti(10,rate); 97 | centerJustifyPrinti(10,discount); 98 | printf("%10i",rate*(qty-discount) ); 99 | printf("\n"); 100 | fillWithDash(80); 101 | printf("\n"); 102 | i++; 103 | } 104 | void printTotals(){ 105 | // printf("%-50s","Amount in Words:" ); 106 | printAndfillWithDash(50,"Amount in Words:"); 107 | printf("%20s","Total:" ); 108 | printf("%10i\n","" ); 109 | printf("%50s","" ); 110 | printf("%20s","Advance:" ); 111 | printf("%10i\n","" ); 112 | printf("%50s","" ); 113 | printf("%20s","Balance:" ); 114 | printf("\n"); 115 | fillWithDash(80); 116 | printf("\n"); 117 | printf("%-50s","*Goods once sold will not be returned." ); 118 | fillWithDash(30); 119 | printf("\n%80s\n","Signature" ); 120 | } 121 | main(){ 122 | 123 | system("cls"); 124 | 125 | printLetterHead(); 126 | 127 | printTableHeader(); 128 | printRow("Safety & Sustainability",1,770,0); 129 | printRow("The Black Economy",1,638,0); 130 | printRow("How to read a book",1,638,0); 131 | printTotals(); 132 | } 133 | -------------------------------------------------------------------------------- /testfile.txt: -------------------------------------------------------------------------------- 1 | this is a test file 2 | --------------------------------------------------------------------------------