jayati, a lot of people commit the mistake of missing out on closing braces because
they don't indent their code.This is what your code looks like when indented.
CODE
// Program to input any string and print the number of spaces stored
// within the string at prime positions.
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
main()
{
char a,name[50];
int f=0, l=0,c=0,k=0;
cout<<"Enter any string "<<endl;
gets(name);
l = strlen(name);
cout<<"The length of the string is "<<l;
cout<<endl;
for(int i=0;i<l;i++)
{
a=name[i];
if (a==' ')// checking if i is prime
k=i+1;
for(int l=1;l<=k;l++)
{
if (k%l==0)
f=f+1;
}
if (f==2)
c = c + 1;
f=0;
}
cout<<endl<<"The no. of spaces at prime position is "<<c;
getch();
return 0;
}
Everyone has their own indentation style, but what I really want to say is that finding out such mistakes is really easy with indented.
Not only that, indented code is more readable.
And as Manny indirectly pointed out, the iostream.h and string.h (even conio.h) are not part of the standard.
Use <iostream> , <string> and <cstring>
Don't use conio.h at all unless your target OS is Windows. functions in conio.h are not portable.