Computer Science, asked by preeja13, 1 year ago

a basic program whose output will be☝☝
pls use nested loop
pls fast

Attachments:

preeja13: please answer fast
Madhu123mri: done
Madhu123mri: #include int main() { int i, j, k, N; printf("Enter N: "); scanf("%d", &N); for(i=1; i<=N; i++) { k = i; // Logic to print numbers for(j=1; j<=i; j++, k++) { printf("%d", k); } printf("\n"); } return 0; }

Answers

Answered by Madhu123mri
0
IN JAVA,

import java.util.*;

class np9

{

public static void main(String args[])

{

int i,j,n,k;

Scanner sc = new Scanner(System.in);

     System.out.println("Enter the no of lines");

n=sc.nextInt();

     for(i=1;i<=n;i++)

     {

k=i;

         for(j=1;j<=i;j++,k++)

         {

             System.out.print(k);

         }

         System.out.println("");

     }

}

}

IN C++,

#include 
int main()
{
int i, j;
for (i=1; i<=5; ++i)
{
for (j=1; j<=i; ++j)
{
printf("%2d", i+j-1);
}
printf("\n");
}
return 0;
}


HERE IS YOUR ANSWER...

HOPE IT HELPS! ^_^

preeja13: please fast
Madhu123mri: class Pyramid { public static void main(String[]args){ int i,j,k; for(i=0; i<5; i++) { for (k=i+1; k<= 2*i+1; k++) { System.out.print( k % 10); } System.out.println(); } } }
preeja13: I can't understand anything is it Java programming or C plus plus
Madhu123mri: It is Jaca
preeja13: I am not talking about Java I am a beginner in basic
preeja13: I am talking about a simple basic program which ends with linenumber and
preeja13: sorry it's not and its end
Madhu123mri: ok
preeja13: please send fast please
preeja13: please send fast I have to learn for my computer exam which is tomorrow please please please send fast
Similar questions