why variable can't add number as suffix like:

int 3a

Recommended Answers

All 4 Replies

Hey Dduleep, if you need to use '3a' as a variable, have you considered using a character array to hold the variable? I've attached some code that should work in the capacity that I just mentioned, for character variable "var"

char var[3]="3a";

I can't be sure, but maybe you are wanting to carry out character arithmetic. If this is the case then I have an example that you can take a look at:

char ch='a';

//take ch from its char value to the its corresponding numerical value
ch-='a';   

//multiply ch's numerical value *3
ch*=3;

//return (3*ch) as an integer
printf("%d", word);

Or maybe you mean to take an integer 'a' and multiply by three. If that is the case, take this example for consideration:

int a, mult_a;

//receive integer variable 'a'
scanf("%d",&a);

//enact a*3 multiplication and store as separate variable (for clarity)
mult_a=3*a;

//return 3a (3*a) 
printf("%d",mult_a);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.