Sunday, March 26, 2023

Aptitude test assistant programmer 2018

 #include <stdio.h>

#include <stdlib.h>

int main()

{

char str[100];

int i;

int space=0;

    printf("Enter a string\n");

    fgets(str,sizeof(str),stdin);

    i=0;

    while(i<=str[i]){

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

        space++;

    }

    i++;

}

printf("Total word count :%d" ,space+1);

 

    return 0;

}

Saturday, March 25, 2023

Codeforce Problem 1703A. YES or YES?

A. YES or YES?
 

There is a string  of length 3, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quotes), where each letter can be in any case. For example, "yES", "Yes", "yes" are all allowable.

Input

The first line of the input contains an integer  (1103) — the number of testcases.

The description of each test consists of one line containing one string  consisting of three characters. Each character of  is either an uppercase or lowercase English letter.

Output

For each test case, output "YES" (without quotes) if  satisfies the condition, and "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).

Example
input
Copy
10
YES
yES
yes
Yes
YeS
Noo
orZ
yEz
Yas
XES
output
Copy
YES
YES
YES
YES
YES
NO
NO
NO
NO
NO
Note

The first five test cases contain the strings "YES", "yES", "yes", "Yes", "YeS". All of these are equal to "YES", where each character is either uppercase or lowercase.

 


Solution in cpp


  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // Write C++ code here
  6. int t ;
  7. cin>>t;
  8. while(t--)
  9. {
  10. string s;
  11. cin>>s;
  12.  
  13. if((s[0]=='Y' or s[0]=='y') and (s[1]=='E' or s[1]=='e') and (s[2]=='s' or s[2]=='S'))
  14. {
  15. cout<<"YES"<<endl;
  16. }
  17. else cout<<"NO"<<endl;
  18. }
  19. return 0;
  20. }

Aptitude test assistant programmer 2018

 #include <stdio.h> #include <stdlib.h> int main() { char str[100]; int i; int space=0;     printf("Enter a string\n")...