print out put like this form
1 2 3 4 5 6
3 5 7 9 11
8 12 16 20

Answer Posted / sanjay bhosale

int *a,n;
printf("\n Enter the number of elements");
scanf("%d",&n);
a = new int[n];
for(int i=0;i<n;i++)
{
a[i] = i+1;
}
printf("\n : Output : \n");
for(int i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
for(int t = n-1;t>0;t--)
{
printf("\n");
for(int i=0;i<t;i++)
{
printf("%d\t",a[i]+a[i+1]);
a[i] = a[i]+a[i+1];
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

program to convert a integer to string in c language'

1984


What is LINKED LIST? How can you access the last element in a linked list?

633


A set of N billiard balls are set on a one-dimensional table. The table is 1 meter long, set north-south with two pockets at either side. Each ball has zero width and there is no friction so it is moving with a fixed velocity of either northward or southward and bounces back in a perfect elastic collision from other balls it encounter on its way (or drop into one of the pockets). Your job is to keep track of the balls movements. Task Please write a program that gets the initial place, speed and direction of all the balls and gives the position of a specific ball after t seconds. Input The first line contains the number of scenarios. Each one of the other lines in the input contains a scenario: The first number, N, is the number of balls; followed by N pairs of numbers: the distance in centimeters from the south end of the table and the speed (positive speed meaning it moves northward); the last two numbers are the number i of the target ball you should track and the time T in seconds. Output The output is a single number for each line which is the place (distance in centimeters from the south end of the table) of the tracked ball after T seconds. Note: There is no new line character at the end of the result. Sample Input 5 1 50 1 1 1000 1 50 1 1 6 1 60 -2 1 6 2 10 1 95 -1 2 30 2 10 1 95 -1 2 60 Sample Output 100 56 48 65 70

2134


What do you mean by invalid pointer arithmetic?

637


What is a sequential access file?

646






What is the difference between procedural and declarative language?

649


Why doesnt that code work?

600


Explain modulus operator.

595


What is a pointer value and address in c?

633


What is the difference between Printf(..) and sprint(...) ?

786


Why is C language being considered a middle level language?

654


What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }

1956


How do I convert a string to all upper or lower case?

627


How does #define work?

646


What is main function in c?

549