pub

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kaushalpkk
Date:
Wed Feb 06 18:12:03 2019 +0000
Commit message:
pub

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 06 18:12:03 2019 +0000
@@ -0,0 +1,110 @@
+#include "mbed.h"
+
+int main() {
+    if(1){
+    //Arithmetic Operators
+    int a = 9,b = 4, c;
+    
+    c = a+b;
+    printf("a+b = %d \n",c);
+
+    c = a-b;
+    printf("a-b = %d \n",c);
+    
+    c = a*b;
+    printf("a*b = %d \n",c);
+    
+    c=a/b;
+    printf("a/b = %d \n",c);
+    
+    c=a%b;
+    printf("Remainder when a divided by b = %d \n",c);        
+    }
+    
+    if(1){
+    //Increment and Decrement Operators
+    int a = 10, b = 100;
+    float c = 10.5, d = 100.5;
+
+    printf("++a = %d \n", ++a);
+
+    printf("--b = %d \n", --b);
+
+    printf("++c = %f \n", ++c);
+
+    printf("--d = %f \n", --d);
+    }
+    
+    if(1){
+    //Assignment Operators
+    int a = 5, c;
+
+    c = a;
+    printf("c = %d \n", c);
+
+    c += a; // c = c+a
+    printf("c = %d \n", c);
+
+    c -= a; // c = c-a
+    printf("c = %d \n", c);
+
+    c *= a; // c = c*a
+    printf("c = %d \n", c);
+
+    c /= a; // c = c/a
+    printf("c = %d \n", c);
+
+    c %= a; // c = c%a
+    printf("c = %d \n", c);
+    }
+    
+    if(1){
+    //Relational Operators
+    int a = 5, b = 5, c = 10;
+
+    printf("%d == %d = %d \n", a, b, a == b); // true
+    printf("%d == %d = %d \n", a, c, a == c); // false
+
+    printf("%d > %d = %d \n", a, b, a > b); //false
+    printf("%d > %d = %d \n", a, c, a > c); //false
+
+
+    printf("%d < %d = %d \n", a, b, a < b); //false
+    printf("%d < %d = %d \n", a, c, a < c); //true
+
+
+    printf("%d != %d = %d \n", a, b, a != b); //false
+    printf("%d != %d = %d \n", a, c, a != c); //true
+
+
+    printf("%d >= %d = %d \n", a, b, a >= b); //true
+    printf("%d >= %d = %d \n", a, c, a >= c); //false
+
+
+    printf("%d <= %d = %d \n", a, b, a <= b); //true
+    printf("%d <= %d = %d \n", a, c, a <= c); //true
+    }
+    
+    if(1){
+    //Logical Operators
+    int a = 5, b = 5, c = 10, result;
+
+    result = (a == b) && (c > b);
+    printf("(a == b) && (c > b) equals to %d \n", result);
+
+    result = (a == b) && (c < b);
+    printf("(a == b) && (c < b) equals to %d \n", result);
+
+    result = (a == b) || (c < b);
+    printf("(a == b) || (c < b) equals to %d \n", result);
+
+    result = (a != b) || (c < b);
+    printf("(a != b) || (c < b) equals to %d \n", result);
+
+    result = !(a != b);
+    printf("!(a == b) equals to %d \n", result);
+
+    result = !(a == b);
+    printf("!(a == b) equals to %d \n", result);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 06 18:12:03 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file