Write a for loop that will read the character in a character type array called text
and write the character backwards into another character type array called back
text. Assume that text contains 80 characters. Use the comma operator within for
loop.
Solution:
#include<stdio.h>
#include<conio.h>
int main()
{
char text[80];
char backtext[80],ch;
int i,j,len=0;
printf("Note: Please end with full stop ");
printf("Enter a string and please End with a . (fullstop) : ");
for(i=0; i<80; ++i)
{
ch=getche();
if(ch== .) // use single quatation
break;
text[i]=ch;
len++;
}
j=len;
for(i=0; i<len; ++i)
{
backtext[i]=text[j-1];
j--;
}
printf(" Revarse text is : ");
for(i=0; i<len; ++i)
printf("%c",backtext[i]);
getch;
}
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.