top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a loop statement that will show the following output

+1 vote
1,062 views

1
12
123
1234
12345

posted Dec 2, 2014 by Vinitha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
#include<stdio.h> 
void main() 
{ 
  int i,j,n; 
  printf("Enter the number of lines:"); 
  scanf("%d",&n); 
  for(i=1;i<=n;i++) 
  { 
    for(j=1;j<=i;j++) 
    { 
     printf("%d",j); 
    } 
    printf("\n"); 
  } 
} 

The output would be 
Enter the number of lines:5 
1 
12 
123 
1234 
12345 
answer Dec 2, 2014 by Shivaranjini
0 votes
#include<stdio.h>
main()
{
  int i,j;
  for(i=1;i<6;i++)
  {
    for(j=1;j<=i;j++)
    printf("%d",j);
    printf("\n");
  }
}
answer Dec 2, 2014 by Chirag Gangdev
Similar Questions
+2 votes
for (a=1; a&lt;=100; a++)

printf (&quot;%d\n&quot;, a * a);
+1 vote
1*8+1= 9
12*8+2=98
123*8+3=987
1234*8+4=9876
12345*8+5=98765
123456*8+6=987654
1234567*8+7=9876543
12345678*8+8=9876543 2
123456789*8+9=987654 321
–1 vote

Determine the set of inputs that will lead to SIGFPE (floating point exception) being triggered in following C program?

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    if(argc != 3 || !atoi(argv[2]))
        return 1;
    return abs(atoi(argv[1])) / atoi(argv[2]);
}
...