how to write a cprogram yo get output in the form
*
***
*****
*******
*********
*******
*****
***
*

Answer Posted / c.p.senthil

description for previous answer posted again

n = 5
loop 1: i = 0 to 4
loop 2: i = 5 to 0

Loop variables => i j k j exp k exp
.....*............0 5 spaces, 1 stars (5-0) (2*0)+1
....***...........1 4 spaces, 3 stars (5-1) (2*1)+1
...*****..........2 3 spaces, 5 stars (5-2) (2*2)+1
..*******.........3 2 spaces, 7 stars (5-3) (2*3)+1
.*********........4 1 spaces, 9 stars (5-4) (2*4)+1
***********.......5 0 spaces, 11 stars(5-5) (2*5)+1
.*********........4 1 spaces, 9 stars (5-4) (2*4)+1
..*******.........3 2 spaces, 7 stars (5-3) (2*3)+1
...*****..........2 3 spaces, 5 stars (5-2) (2*2)+1
....***...........1 1 spaces, 3 stars (5-1) (2*1)+1
.....*............0 5 spaces, 1 stars (5-0) (2*0)+1

..........generalising expressions => (n-i) (2*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

What are the parts of c program?

743


What is void main () in c?

832


How to implement a packet in C

2483


What is FIFO?

760


Explain what are the __date__ and __time__ preprocessor commands?

713






How do we print only part of a string in c?

681


What is extern storage class in c?

613


What are the advantages of Macro over function?

1426


Can include files be nested? How many levels deep can include files be nested?

739


what is the height of tree if leaf node is at level 3. please explain

1706


What are the types of macro formats?

698


Write a program of prime number using recursion.

709


Why C language is a procedural language?

700


What should malloc() do?

736


difference between Low, Middle, High Level languages in c ?

1738