123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program to find out the rightmost occurence of an input character in an input string.

--------------------------------------------------------------------------------



#include <stdio.h>
#include <conio.h>
int strindex(char s[],char t);
void main()
{

char s[80],t;
int a=0;
clrscr();
printf("
Enter main string(i.e. s):-<BR>);
gets(s);
printf("
Enter the character to be searched(i.e. t):- ");
t=getchar();
a=strindex(s,t);
if (a>=0)
printf("

The required character is found at position %d.",a);
else
printf("

The required character is not found in the string.");
getch();
}


int strindex(char s[],char t)
{
int i=0;
for (i=strlen(s);i>=0;i--)
{
if (s[i]==t)
return(i);
}
if (i<0)
return(-1);
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG