Error Finding

I am writing a program to identify the character entered by the user.Please find the errors in the following program. Thanx it advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
  #include<iostream>
void main()
{
	char a;
	cout<<"Enter a character=";
	cin>>a;
	if(a>='a')&&(a<='z')
		cout<<"It's a character.";
	else if (a>=0)&&(a<=9)
		cout<<"It's a number.";
	else
		cout<<"It's a special character";
}
You should have a compiler. Compiler should be able to identify some errors. It is very useful to learn to read the feedback of the compiler. What does your compiler say about your code?
2:11: error: '::main' must return 'int' In function 'int main()'
5:2: error: 'cout' was not declared in this scope 
5:2: note: suggested alternative: In file included from 
1:0: /usr/include/c++/4.7/iostream:62:18: note: 'std::cout' 
6:2: error: 'cin' was not declared in this scope 
6:2: note: suggested alternative: In file included from 1:0: /usr/include/c++/4.7/iostream:61:18: note: 'std::cin' 
7:14: error: expected identifier before '(' token 
7:14: error: expected ';' before '(' token 
9:18: error: expected identifier before '(' token 9:18: error: expected ';' before '(' token
1. main() should return int not void.
2. You are not using the std namespace, and so where is cout from?
3. Your if and else if syntax

Aceix.
Last edited on
Thanx guys owe you big time. :)
Topic archived. No new replies allowed.