Header Ads Widget

Pages in PDF | Wipro previous year question paper solution

Problem:-

An online printing application has a special way after printing pages in a PDF file. A maximum of 9 lines can be printed on one page the application manager wishes to analyze how many pages have an even number of lines printed on the PDF . for this purpose the number of lines printed on each page of the PDF file is gathered as a concatenated string. The number of digits  in the string represents the number of pages in the PDF and each digits the number of lines printing on that page of the PDF.

Write an algorithm to find the pages with an even number of lines printed on them.

Input

the first line off the input consist of a string numlines, representing the number of lines printed on each page 

output:-  Print a string representing the number of pages with n even number of lines printed on them , without spaces in the same order as in the input string . If no page has even lines then print "NA";

Example;-

input:-

33423968

Output:-

4268

Explanation:-   From all the pages, four pages have even lines printed on them 4,2,6,8   So the output is 4268.

Code:-

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int f=0;
for(int i=0;s[i];i++)
{
// 48 is the ascii of 0
// when we substract 48
// it will convert it into int data type
int a=s[i]-48;
if(a%2==0)
{
           f=1;
cout<<s[i];
        }
}
    // if there is no even line
    if(f==0)
        cout<<"NA";
return 0;
}

Output:-

33423968
4268



Recommended Post:

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-


Post a Comment

0 Comments