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 :: how to split string into words c++ 
Cpp :: string length in c++ 
Cpp :: c++ string find example 
Cpp :: C++ float and double Different Precisions For Different Variables 
Cpp :: c pre-processor instructions 
Cpp :: iterate through list c++ 
Cpp :: doubly linked list in cpp 
Cpp :: how to make Dijkstra in c++ 
Cpp :: how to get hcf of two number in c++ 
Cpp :: c++ if example 
Cpp :: stack c++ 
Cpp :: quicksort 
Cpp :: vector library c++ 
Cpp :: c++ program to generate all the prime numbers between 1 and n 
Cpp :: print hello world c++ 
Cpp :: vector of vectors of pairs c++ 
Cpp :: why convert char* to string c++ 
Cpp :: read string with spaces in c++ 
Cpp :: c++ print 
Cpp :: abstraction in cpp 
Cpp :: walk filesystem in c++ 
Cpp :: c++ fill two dimensional array 
Cpp :: how to remove the scroll bar in pyqt6 
Cpp :: min heap stl 
Cpp :: C++ Arrays and Loops 
Cpp :: add input in c++ 
Cpp :: std::future 
Cpp :: DS1302 
Cpp :: time complexity 
Cpp :: for_each c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =