Program to print the following series:- 1 333 555557777777....and so on upto nth term.?

Answers (1)

// C++ program to print the series 
// 2, 1, 4, 3, 6, 5, …. up to N terms
#include <iostream>
using namespace std;

// Function to print the series
void printPattern(int N)

    for (int i = 1; i <= N; i++)

        // Find and print the ith term
        cout <<" "<<((i % 2 == 0) ? (i - 1) : (i + 1));
    

// Driver code
int main()

    // Get the value of N
    int N = 10;

    // Print the Series
    printPattern(N);

    return 0;

 

Preparation Products

Knockout NEET May 2023 (Easy Installments)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 5499/-
Buy Now
NEET Foundation 2023

-Adaptive Time Table -450 hours of Video Lectures -NCERT Solutions -CBSE Previous Year Papers -Chapter wise Tests.

₹ 14999/-
Buy Now
NEET Foundation + Knockout NEET 2025

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 34999/-
Buy Now
Knockout JEE Main April 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
Buy Now
Knockout NEET Aug 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
Buy Now
Boost your Preparation for JEE Main with our Foundation Course
 
Exams
Articles
Questions