WRITE A PROGRAM TO DISPLAY THE PATTERN
@
@ @
@ @ @
@ @ @ @
Answers
Answer:
These are the required codes for the question.
1. In Java.
public class Pattern {
public static void main(String args[]) {
for(int i=1;i<=4;i++) {
for(int j=1;j<=i;j++)
System.out.print("@ ");
System.out.println();
}
}
}
2. In Python.
for i in range(4):
for j in range(i+1):
print("@ ",end=" ")
print()
OR
print("\n".join(str("@ ")*i for i in range(1,5)))
3. In C
#include <stdio.h>
int main() {
for(int i=1;i<=4;i++) {
for(int j=1;j<=i;j++)
printf("@ ");
printf("\n");
}
return 0;
}
4. In C++
#include <iostream>
using namespace std;
int main() {
for(int i=1;i<=4;i++) {
for(int j=1;j<=i;j++)
cout<<"@ ";
cout<<endl;
}
return 0;
}
•••♪