Termination of loops.

Aug 26, 2014 at 1:17pm
I am making a prog to accept a character and display four successive characters. At present i am able to accept and display all the characters after the entered character. Pls help :) Thanx in advance.

// Just Rahul Prog-7
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char a;
cout<<"Enter a charcter=";
cin>>a;
cout<<"Successive four charcters are=";
for(;a++;a<=4)
{
cout<<a<<",";
}
getch();
}
Aug 26, 2014 at 1:24pm
You have your for-loop arguments swapped. You need to make a secondary variable so you know when you are 4 characters after the original.
Last edited on Aug 26, 2014 at 1:25pm
Aug 26, 2014 at 2:07pm
Thanks but could you show this to me as code.
Aug 26, 2014 at 2:10pm
int b = a;
Topic archived. No new replies allowed.