immannino / viral-math-problem

How do computers solve - 6 / 2 * (1 + 2) ?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do computers solve - (6 / 2 * (1 + 2) ?

C answer - 9

code:

#include "stdio.h"

int main() {
    int a = 6 / 2 * ( 1 + 2);
    printf("C answer - %d\n", a);

    return 0;
}

Golang answer - 9

code:

package main

import "fmt"

func main() {
	a := 6 / 2 * (1 + 2)

	fmt.Printf("Golang answer - %d\n", a)
}

Node.JS answer - 9

code:

const a = 6 / 2 * (1 + 2)
console.log(`Node.JS answer - ${a}`)

Deno answer - 9

code:

const a = 6 / 2 * (1 + 2)
console.log(`Deno answer - ${a}`)

Python2 answer - 9

code:

a = 6 / 2 * ( 1 + 2)

print("Python2 answer - " + str(a))

Python3 answer - 9.0

code:

a = 6 / 2 * ( 1 + 2 )

print("Python3 answer - " + str(a))

Ruby answer - 9

code:

a = 6 / 2 * (1 + 2)

puts "Ruby answer - #{a}"

About

How do computers solve - 6 / 2 * (1 + 2) ?


Languages

Language:Shell 66.9%Language:JavaScript 8.0%Language:Python 7.6%Language:C 7.5%Language:Go 7.0%Language:Ruby 3.0%