C Program to TO REVERSE THE GIVEN STRING using Pointers

C Program to TO REVERSE THE GIVEN STRING using Pointers


#include
#include
void strev(char *str1, char *str2);
void main()
{
char *str1, *str2;
clrscr();
printf("\n\n\t PLZ ENTER A STRING...: ");
gets(str1);
strev(str1,str2);
printf("\n\t YOUR THE REVERSED STRING IS...: ");
puts(str2);
getch();
}
void strev(char *str1, char *str2)
{
int i = 0, len = 0, r = 0;
while(*(str1+len)!='\0')
len++;
for(i=len-1; i>=0; i--)
{
*(str2+r) = *(str1+i);
r++;
}
*(str2+r) = '\0';
}





2 comments:

  1. A C program to perform the following?
    The program should meet the following objectives:
    1. To determine the number of items purchased per customer (it should be in the range of 1-10)
    2. To input price per item.
    3. To determine if there are new customers and repeat steps 1 and 2.
    4. To calculate and output total expenses spent by all customers visiting the shop on a particular day
    5. To determine and output the number of customers
    6. To calculate and output the average spent by a customer

    PLEASE REPLY

    ReplyDelete
  2. PLSEND THE LINK TO GREETINGSONLY(at)Gmail[dot]com

    ReplyDelete