top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to generate the following series in C language?

+1 vote
254 views

I want to generate the following series in C language, please help.

1
2 3
3 4 5
4 5 6 7
5 6 7 8 9
6 7 8 9 10 11
posted Apr 8, 2014 by Arjuna

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

1 Answer

0 votes
print_series()
{
  for (i=1; i<7;i++)
  {
    for (j=0; j<i;j++)
    {
      printf("%d ", i+j);
    }
    printf("\n");
  }
}
answer Apr 8, 2014 by Salil Agrawal
Similar Questions
+3 votes
#include<stdio.h>
#include<string.h>

int main()
{
    char ptr[]= {'a','b','c','0','e'};
    char str[]= "abc0e";
    printf("\nptr = %s\t len = %d\n",ptr, strlen(ptr));
    printf("\nstr = %s\t len = %d\n",str, strlen(str));
    return 0;
}

Output : ptr = abc0e len = 6
str = abc0e len = 5

Why the length for ptr is 6 ? Can someone please explain it ?

+1 vote

JVM provides garbage collector. Can we do in C ? And what are the efficient ways to implement it in C lang ?

0 votes

Can anyone help me with a C program to design a simple state machine by using macros?

Requirement
S1,S2,S3,S4 are the states and E1, E2,E3,E4,E5,E6,E7,E8 are events ...

when states moving from one state to another respective event should trigger
s1 to s2 ------> E1
s2 to s3 ------> E2
s3 to s4 ------> E3
s4 to s1 ------> E4
s1 to s4 ------> E5
s4 to s3 ------> E6
s3 to s2 ------> E7
s2 to s1 ------> E8

Please share the C program

...