Answer to Question #178829 in C++ for Vijay Raj

Question #178829

Implement a C++ program to define function named as ext, to extract the digits that located at even and odd position of five digit number and show the result.


Runtime Input :

00156


Output :

016

05


1
Expert's answer
2021-04-07T01:57:46-0400
#include <string>
#include <iostream>
using namespace std;
void ext(int x){
    string str = to_string(x);
    cout<<"0";
    for(int i = 0; i < str.length(); i++, i++)
        cout<<str[i];
       
    cout<<"\n0";
    for(int i = 1; i < str.length(); i++, i++)
        cout<<str[i]<<endl;
}
int main(){
    int n;
    cout<<"Runtime Input:\n";
    cin>>n;
    cout<<"Output:"<<endl;
    ext(n);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS