What are strings?

340 views

There is a recent tweet in which a lady said 1+2=12.

Obviously that is wrong but everyone keeps saying “it’s wrong unless we are talking about strings”

What are strings?

Edit: thank you all for explaining:) have a cookie 🍪 and a wonderful day

In: 6

10 Answers

Anonymous 0 Comments

Ohh they mean programming. In programming languages we different types of variables. You can store information in a variable. If you want to store something numerical you are going to use something like integer format or float. Ints are intigers so if a=2 a is an integer. If a=2.5 a is a float. The computer handles these formas differently. Now strings are variables useful for storing text. If a=”yo yo yo Mr. White!” a is a string. Its a string of characters. If you want a number to be handled like a characters so no mathematical value assigned to it: a=”2″. a is a string containing the character 2.

You can do operations with strings like add them up. If you have two number like ints a=5, b=2 then a+b=7 it will add them up. But if you store characters in a string: a=”yo yo yo ” and b=”Mr. White!” then a+b will put the two strings together in order so a+b=”yo yo yo Mr. White!”. Similarly if a=”1″ and b=”2″ then a+b=”12″. Not the number 12 but the characters 1 and 2.

You are viewing 1 out of 10 answers, click here to view all answers.