Computer Science, asked by vinubindu147, 8 months ago

program to check whether a characters is present in a string in c++​

Answers

Answered by ItsAadiBoyz77
1

Answer:

#include <stdio. h>

#include<string. h>

int main(void) {

char str[50],c;

int temp=0,i;

printf("\nEnter the string : ");

scanf("%s",str);

printf("\nEnter the char to find : ");

Answered by prakhargupta3301
0

Hi.

This is a program that takes a string, then checks if it has a certain character in the string.

____

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#define size 10

int check(char[],char);

void main()

{

clrscr();

char str[10],c;

cout<<"Enter string:";

gets(str);

cout<<"Enter character to check:";

cin>>c;

if(check(str,c))

cout<<c<<"is present in"<<str;

else

cout<<c<<"isn't present in"<<str;

getch();

}

int check(char x[],char y)

{

for (int i=0;i<size;i++)

{

if(x[i]==y)

return 1;

}

return 0;

}

________________

Mark as brainliest :D

Similar questions