Peoples i have tried to make this simple progrem in C...
that will print alphabets A to Z and their equivalent ASCII code.. like this
A 65
B 66
.
.
.
Z

here is da source code...

int main (void)
{
    char code;
    for(code = "A";code <= "Z"; code += 1)
    printf("%c, %d", code code);
    getch();
}

tell me where is da problem

what is the output of your program? The code looks ok, except I'd make code an int instead of char but that shouldn't cause any problem.

The format string needs a '\n' for line feed ("%c, %d\n",

Peoples i have tried to make this simple progrem in C...
that will print alphabets A to Z and their equivalent ASCII code.. like this
A 65
B 66
.
.
.
Z
here is da source code...

Please use English. It's "here is the source code. Unless your name is Stepin Fetchit,. Thanks. And use CODE tags...

int main (void)
{
	char code;
	for(code = "A";code <= "Z"; code += 1)
	printf("%c, %d", code[B],[/B] code);
	getch();         //  ^
}
commented: If you can't use basic grammar, you can't code. +1

while compiling it shows this type of error

"Nonportable pointer conversion"

"A" is a string.
'A' is a char.
code is a char.

Hope this helps.

while compiling it shows this type of error

"Nonportable pointer conversion"

You're right -- I didn't read it hard enough. Should use single quotes, not double quotes, like this: for(code = 'A';code <= 'Z'; code += 1)

>I suppose you could do this, just to see who's awake
You're a cruel, cruel man, Salem.

Yes the problem is solved the mistake was the double quote AND the comma between the
code code

Thanks peoples out therir who replied
Here is the full and final program

void main (void)
{
	char code;
	for(code='A';code<='Z';code = code+1)
	printf("%c %d\n", code, code);
	getch();
}

>Here is the full and final program
I'm going to pull out my chainsaw now.

>void main (void)
main returns int. No excuses. And when you say you'll return int, you'd better actually return a value too. 0 is a good choice.

>for(code='A';code<='Z';code = code+1)
For future reference, only the decimal digits are required to be consecutive. It's possible that there are non-alphabet characters between 'A' and 'Z' depending on the character set. Also, code = code + 1 is pretty verbose. You can get away with ++code .

>printf("%c %d\n", code, code);
You absolutely must include stdio.h if you want to use a function that takes variable arguments. If you don't, you must provide a prototype yourself. Otherwise it's undefined behavior. I suggest getting into the habit of always including the headers that you use stuff from in your programs.

>getch();
I'd recommend using getchar instead. It's standard, comes with stdio.h, and works everywhere. With getch you have to include the non-standard conio.h, and it's not likely to work in many places.

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.