Header Ads Widget

find the odd digits | wipro previous year question

 Question:-

A society has multiple apartments, and each apartment has a certain number of people living in it. A maximum of 9 people is allowed to live in one apartment. The society secretary would like an automated system that takes the number of people living in each apartment and combines it to form a string, providing information for all the apartments where an odd number of people are living.


Write an algorithm to make an automated system which will find all the odd digits from the given number.

Input:-

The input consists of a string:- numPeople, representing the number of people who live in each apartment.

Output:-

Print a string representing all the odd numbers of people living in the apartments.

Note:- If no odd number of people are found in the given input, output would be empty.

Example

Input:-

1234567

Output:-

1357

Code:-


#include <bits/stdc++.h>
using namespace std;

int main()
{
string s;
cin>>s;
for(int i=0;s[i];i++)
{
int x=s[i]-48;
if(x%2!=0)
cout<<s[i];
}
return 0;
}

output:-

1234567
1357

Recommended Post:

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

  • Engineering mathematics -4 MCQs
  • CSS (Computer cyber security ) MCQS


  • Wipro previous question paper solution , wipro previous year question papers with answers pdf,
    wipro previous year questions, wipro question paper 2021,wipro online assessment test questions and answers,wipro model papers 2020,wipro previous year coding questions,wipro online assessment test questions and answers 2022,wipro aptitude questions with answers pdf,wipro question paper 2021,wipro model papers 2020,wipro previous year coding questions,10 wipro placement papers,
    wipro previous year question papers with answers pdf

Post a Comment

0 Comments