File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ //Solution by Abhi, CSE
2
+
3
+ #include <iostream>
4
+ #include <string.h>
5
+ #include <stdio.h>
6
+ using namespace std ;
7
+ int main ()
8
+ {
9
+ char * a ;
10
+ int i ,j ,c ,flag = 0 ,size ;
11
+ cout <<"ENTER THE SIZE:- " ;
12
+ cin >>c ;
13
+ a = new char [c ];
14
+ cout <<"\n ENTER THE STRING:- " ;
15
+ for (j = 0 ;j < c ;j ++ )
16
+ cin >>a [j ];
17
+ size = c - 3 ;
18
+ if ((a [0 ]== 'b' )|| (a [0 ]== 'B' ))
19
+ {
20
+ for (i = c ;i >=size ;i -- )
21
+ {
22
+ if (isalpha (a [i ]))
23
+ {
24
+ continue ;
25
+ }
26
+ else
27
+ {
28
+ cout <<"\nin the else loop" ;
29
+ flag = 1 ;
30
+ break ;
31
+ }
32
+ }
33
+ }
34
+ else
35
+ {
36
+ flag = 2 ;
37
+ }
38
+ if (flag == 0 )
39
+ {
40
+ cout <<"\nTHE GIVEN STRING STARTS WITH 'B' AND ENDS WITH 3 CHRACTERS\n" ;
41
+ }
42
+ else if (flag == 1 )
43
+ {
44
+ cout <<"\nTHE GIVEN STRING STARTS WITH 'B' BUT IT DOESNOT END WITH THREE CHRACTERS\n" ;
45
+ }
46
+
47
+ else if (flag == 2 )
48
+ {
49
+ cout <<"\nTHE GIVEN STRING DOESNOT START WITH 'B'\n" ;
50
+ }
51
+ return 0 ;
52
+ }
You can’t perform that action at this time.
0 commit comments