i have complete a code . but i dun understand why need to put[]after a variable. What it mean? Why need to put char in front of variable?When i make statement number1=10, i dun need to put int in front of the statement and dun need [].
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <stdio.h>
int main()
{
char answer1,answer2;
char question1[] = "What is your name?";
char question2[] = "where you live?";
printf("%s\n",question1);
scanf("%s",&answer1);
printf("%s\n",question2);
scanf("%s",&answer2);
printf("Hello!%s from %s",answer1,answer2);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11
#include <stdio.h>
int main()
{
int number1,number2,multipliednumber;
number1=10;
number2=25;
multipliednumber= number1*number2;
printf("%d*%d=%d\n",number1,number2,multipliednumber);
return 0;
}
These characters [] mean the variable is an array, in this case, an array of characters that are comprised of the character string on the right side of the '=' sign.
you also have to notify the program initially what type of variable youre trying to place into the "container" for example int for numbers and strings for char arrays. Once they have been declared you can just use the name of the variable to change it without needing to declare the type again.