2 Replies - 1961 Views - Last Post: 19 November 2012 - 02:07 AM Rate Topic: -----

#1 Diljit Dosanjh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-November 12

Left Sided Triangle HELP!

Posted 19 November 2012 - 12:34 AM

what changes should i do in this c program to get a Left Sided Star Triangle
#include<stdio.h>
  #include<conio.h>
  void main()
  {
	 int i,j,n,k;
	 printf("Enter No. Of lines :");
	 scanf("%d",&n);

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

		 {
		 for(j=n-i;j>=1;j--);
		 {

			 printf("*");


		 }
		 printf("\n");
		 }

	 getch();
	 }


MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 19 November 2012 - 04:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Left Sided Triangle HELP!

#2 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: Left Sided Triangle HELP!

Posted 19 November 2012 - 01:51 AM

I am sorry to say this, but your code doesn't print a triangle at all. For it to print it correctly, you need to remove the semicolon for the for loop.Once you get the code for printing the required triangle, then look at my suggestion below.

Spoiler


regards,
Raghav

This post has been edited by raghav.naganathan: 19 November 2012 - 02:14 AM

Was This Post Helpful? 0
  • +
  • -

#3 Adak  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,168
  • Joined: 01-April 11

Re: Left Sided Triangle HELP!

Posted 19 November 2012 - 02:07 AM

You need an if statement to use your i and j variables, so the program knows when to print the stars.

You have the right idea, but please don't post code without code tags - click on the [code] icon in the editor.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1