>#include<iostream.h>
>#include<stdio.h>
Don't use iostream.h, it's not valid C++ anymore. New compilers will refuse to compile your code. Also, stdio.h is deprecated in C++. The two headers you should be using are:
#include <iostream>
#include <cstdio>
And because the modern C++ standard library is in the std namespace, you need to qualify it. The easiest way to do that is
using namespace std;, but that's generally not a good idea for reasons that you'll learn later.
>void main()
void main is wrong in both languages. It's never been correct in 40 years. main returns an int, always, without fail. This is your template for all new programs in C++:
#include <iostream>
using namespace std;
int main()
{
}
You don't need to return anything because 0 is returned implicitly by default. And this is the template for C:
#include <stdio.h>
int main ( void )
{
return 0;
}
The latest C standard also returns 0 implicitly, but it's not widely implemented enough yet that you can adopt the convention. Not to mention the C community is leaning toward considering it bad practice to use that feature.
>gets(a);
gets is a bad idea. It's never safe, so you should just forget that it exists at all. In C, the replacement is fgets, and in C++ the replacement is getline.
>cout<<a[x];
I highly recommend not mixing C and C++ style I/O.
>but when I code I tend to use both C and C++
That's a mistake. There are subtle differences between C and C++, and unless you're an expert in both languages, mixing them with burn you eventually.