Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:32+00:00 2026-06-14T14:51:32+00:00

I was wondering how to compare one array into two arrays but with some

  • 0

I was wondering how to compare one array into two arrays but with some rules:
In my code I need to type 8 digits to make the cycle – OK, I did it. Now I need to compare the array = m[3] to two different arrays:

first array must be with (if m[i]%2==0) ...

second array must be with (if m[i]%2!=0) ...

So if I type from keyboard those three rows in my Main array (m[3]):

12345678
12345689
12344331

After typing them, I need to set the in those two different arrays and here I think I need to make the char(string) to integer to make the check with %, or to somehow do the check only on the last digit (it will work the same way).
So here goes the next step after typing the 3 rows:

arrA=12345678
arrB=12345689 12344331


#include <iostream>
#include <conio.h>
#include <string>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
int main()
{
    int i,n;
    char m[3];
    for(i=1; i<=3; i++)
    {
        cout<<i<<". Fak nomer: "<<endl;
        do
        {
            cin>>m[i];
            gets(m);
        }
        while (strlen(m)!=7);
        cout<<"As integer: "<<atoi(m);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:51:33+00:00Added an answer on June 14, 2026 at 2:51 pm

    From what I understand, you are trying to read three positive integers into an array called m, but you want to ensure the following:

    • all three number have eight digits
    • the first number (m[0]) is even
    • the second number (m[1]) is odd

    It would be a lot easier if m can be an array of integers, then a conversion from a string to an int is not required. To read the three integers from the console, use this:

    // m is now an array of integers
    int m[3];
    // loops from m[0] to m[2]
    for(int i = 0; i < 3; i++)
    {
        cout<<i<<": "<<endl;
        do
        {
            cin>>m[i];
        }
        while (!(m[i] >= 1e7 && m[i] < 1e8));
        // m[i] must be greater than or equal to 10000000 and less than 100000000
        //  before continuing
    }
    

    By making m an array of integers, checking for even or odd becomes easier:

    if (m[0] % 2 == 0)
        cout << "m[0] is even" << endl;
    if (m[1] % 2 != 0)
        cout << "m[1] is odd" << endl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how I would compare two 2-dim lists by their location. For
I'm trying to compare two 2D arrays in PHP and my head is hurting
I was wondering if there somebody knows if there are some benchmarks which compare
I have two arrays. In each array I have objects with lots of properties
I was wondering if i can compare two intergers in my sql statement. I
To compare byte by byte surely works. But I am wondering if there are
I have a C++ application in which I need to compare two values and
Right, so let's say I want to compare two BitmapDatas. One is an image
i'm wondering how can I compare in C language, a number I put on
Wondering if someone could please explain the difference between these two queries and advise

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.