Question #23916

what will be the output of the following program:
#include<iostream.h>
#include<ctype.h>
typedef char str[80];
void main()
{
char *notes;
str[80]="vR.2GooD";
int l=6;
notes=str;
while(l>3)
{str[l]=(isupper(str[l])?tolower(str[l]):toupper(str[l]));toupper(str[l]);
cout<<notes<<endl;
l--;
notes++;
}
}
The text says that the output is
VR2Good
R2Good
good how will i get that output?

thanks in advance........................

Expert's answer

#include <iostream>
#include <conio.h>
#include <ctype.h>

using namespace std;

char str[80] = "vR2GooD";

void main()
{
char* notes = str;
int l = 6;

while (l > 3)
{
str[l] = tolower(str[l]);
cout << notes << endl;
l--;
notes++;
}
_getch();
}
LATEST TUTORIALS
APPROVED BY CLIENTS