answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<string.h>

main()

{

char a[24];

int i,count=0,j=0,stlen,k,substlen,sig=0;

gets(a);

for(i=0;i<strlen(a);i++)

{if(a[i]==' ')

break;

else j++;}

stlen=j;

substlen=strlen(a)-j-1;

for(i=0;i<=stlen-substlen;i++)

{count=0;

for(k=i+substlen-1;k>=i;k--)

{if(a[k]!=a[k+stlen-i+1])

break;

else count++;}

if(count==substlen)

{sig=1;

break;

}

}

printf("%d",sig);

}

input-

11100101 1001

110010 111

output-

1

0

note -give the main string and the substring(to be checked) seperated by a space.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Check the functions or methods in the language of your choice; there probably already is something pre-programmed.

If this is a programming exercise, you would have to write a loop that checks from each position of the string in which you are searching. Write a second loop that compares each character.

Check the functions or methods in the language of your choice; there probably already is something pre-programmed.

If this is a programming exercise, you would have to write a loop that checks from each position of the string in which you are searching. Write a second loop that compares each character.

Check the functions or methods in the language of your choice; there probably already is something pre-programmed.

If this is a programming exercise, you would have to write a loop that checks from each position of the string in which you are searching. Write a second loop that compares each character.

Check the functions or methods in the language of your choice; there probably already is something pre-programmed.

If this is a programming exercise, you would have to write a loop that checks from each position of the string in which you are searching. Write a second loop that compares each character.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Check the functions or methods in the language of your choice; there probably already is something pre-programmed.

If this is a programming exercise, you would have to write a loop that checks from each position of the string in which you are searching. Write a second loop that compares each character.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program to check the presence of a substring in a given string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you show the location of an occurrence of the letter e in a string using javascript?

The location of a substring within a string in JavaScript can be found using the indexOf() method of the string type. That method will return the placement of a string as a numerical index, starting from 0. The method takes two arguments. The first is the substring you're looking for. In this case "e." The second argument is optional, and it's the "start" argument. If you define it, you define the index from which JavaScript will start looking for the substring. By default, this index is 0 (zero.) If you want to find all of the occurrences of a string using this method, you have to write a loop. To see a working example of that, check out the JSFiddle in the related links. I've also attached a good lesson on JavaScript strings in PDF.


Write a c program to check whether a string follows English capitalization rules?

Active Time spent online


Write a program that stores vowels in an array When you program is given a character it should indicate whether the character is vowel or not?

That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


Calculate the check sum8 of hex string 0221323DA3B4?

The check sum8 of hex string 0221323DA3B4 is E9.

Related questions

Write a Java Program to find occurences of given word in a text?

Check the documentation of the String class, for a method that searches for a substring.


How do you show the location of an occurrence of the letter e in a string using javascript?

The location of a substring within a string in JavaScript can be found using the indexOf() method of the string type. That method will return the placement of a string as a numerical index, starting from 0. The method takes two arguments. The first is the substring you're looking for. In this case "e." The second argument is optional, and it's the "start" argument. If you define it, you define the index from which JavaScript will start looking for the substring. By default, this index is 0 (zero.) If you want to find all of the occurrences of a string using this method, you have to write a loop. To see a working example of that, check out the JSFiddle in the related links. I've also attached a good lesson on JavaScript strings in PDF.


Can you write a C program to check whether a string is an IP address or not?

Use the Exception class and type converters.


Write a c program to check whether a string follows English capitalization rules?

Active Time spent online


Write a program that stores vowels in an array When you program is given a character it should indicate whether the character is vowel or not?

That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


What are examples of a palindrome program forward and backwards?

To check if a string is a palindrome, point to each end of the string and work inwards towards the middle. If the characters pointed at differ, the string is not a palindrome. When the pointers meet or cross each other, the string is a palindrome. Note that the string cannot contain whitespace or punctuation and comparisons must not be case-sensitive.


Calculate the check sum8 of hex string 0221323DA3B4?

The check sum8 of hex string 0221323DA3B4 is E9.


Write programs for String Reversal and Palindrome check?

Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.


Write a PHP program to check whether the string is palindrome or not?

You can do this: &lt;?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }


What is presence check?

presence check is when you validate a pieve of unsure information on bullying eg, therefore if you were to be validating the real gender of someone then presence check would not apply to you, whereas if you were to be validating a presence of a person this would very much apply to you.