Studytonight is now part of the GUVI universe. Explore GUVI →
🤩 New Cool Developer Tools for you. Explore →
FREE JavaScript Video Series Start Learning →
Signup/Sign In
Tests
MCQs to test your knowledge.
Compilers
Compilers to execute code in browser.
Index
LAST UPDATED: MARCH 17, 2022

C++ Program To Print INDIA Pattern As Given Below

Here, in this tutorial we will be learning about how to print INDIA in the given pattern as follows:-

I

IN

IND

INDI

INDIA

The basic approach will be to print the letters of the work in particular loops starting from the first index to the counter value. First of all, we need to apply the for loop for selecting the specific letter from the word one by one in each pass, and then the inner loop will be for the starting index and the counter value.

C++ Program To Print The Pattern

#include<iostream>
using namespace std;
int main()
{
char s[]="INDIA";
int i,j;
for(i=0;s[i];i++){
 for(j=0;j<=i;j++){
 cout<<s[j];
 }
 cout<<"\n";
 }
 
 return 0;
}


I
IN
IND
INDI
INDIA

Conclusion

In this tutorial, we have seen the basic implementation through the C++ program that how we can create the given pattern of the "INDIA" word.



About the author:
Nikita Pandey is a talented author and expert in programming languages such as C, C++, and Java. Her writing is informative, engaging, and offers practical insights and tips for programmers at all levels.

Learn to Code
Learn and practice coding side-by-side.
NEW
C language Course
115+ coding exercises
Javascript Course
85+ coding exercises

AltStyle によって変換されたページ (->オリジナル) /