wap in java or c++ using for loop
Attachments:
Answers
Answered by
3
#include<stdio.h>
int main(){
int i,j,n,k;
printf("Enter the range\n");
scanf("%d",&n);
k=n+1;
for(i=1;i<=n;i++){
for(j=1,k=k-i;j<=i;j++){
printf("%d",k);
k++;
}
printf("\n");
}
return 0;
}
this will give output as:-
5
45
345
2345
12345
sikhi:
hope it will help you
Answered by
2
Write a program in Java or C++ to display the following pattern.
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
The given code is written in Java Language.
import java.util.*;
class Pattern
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number of rows for the pattern: ");
int n=sc.nextInt();
for(int i=n;i>=1;i--)
{
for(int j=i;j<=n;j++)
System.out.print(j+" ");
System.out.println();
}
}// end of main()
}// end of class.
Similar questions
Physics,
7 months ago
Social Sciences,
7 months ago
Math,
7 months ago
Science,
1 year ago
Chemistry,
1 year ago