Search
 
SCRIPT & CODE EXAMPLE
 

CPP

odd numbers 1 to 100

#include <iostream>
using namespace std;
int main()
{
   

    cout << "odd numbers from 1 to 100 : ";
    for (int i = 0; i <= 100; i++)
    {

        if (i % 2 != 0)
        {
            cout << i << ",";
        }
    }
}
Comment

even and odd numbers 1 to 100

#include <iostream>
using namespace std;
int main()
{
    string even = "";
    string odd = "";

    for (int i = 0; i <= 100; i++)
    {

        if (i % 2 == 0)
        {
            even.append(to_string(i) + ", ");
        }
        else
        {
            odd.append(to_string(i) + ", ");
        }
    }

    cout << "these numbers are even  
"
         << even << endl;
    cout << "these numbers are odd  
"
         << odd << endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Implicit conversion casting 
Cpp :: c++ comment 
Cpp :: cpp foreach 
Cpp :: c++ char 
Cpp :: && c++ 
Cpp :: kmp c++ 
Cpp :: cpp compare strings 
Cpp :: inverted triangle c++ 
Cpp :: c++ square and multiply algorithm 
Cpp :: c++ method name 
Cpp :: c ++ The output should be (abc),(def),(ghw) 
Cpp :: c++ convert int to string with a fixed number of digits 
Cpp :: c++ iterate through constant list 
Cpp :: CPP print executable name 
Cpp :: c++ round number to 2 decimal places 
Cpp :: Minimizing the dot product codechef in c++ 
Cpp :: c++ copy vector 
Cpp :: windows servis from console app 
Cpp :: find min and max in array c++ 
Cpp :: how to make a defaule conrstrocr in c++ classes 
Cpp :: youtube to facebook link converter 
Cpp :: cpp fread 
Cpp :: how to draw a rectangle with diagonals and axes of symmetry in c ++ in the console? 
Cpp :: estimateaffine3d example c++ 
Cpp :: map::begin 
Cpp :: c++ insertion in astack 
Cpp :: c++ watch a variable 
Cpp :: displaying m images m windows opencv c++ 
Cpp :: To toggle (flip the status of) the k-th item of the set 
Cpp :: C++ (gcc 8.3) sample 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =