Assume that the int variables i and j have been
declared, and that n has been declared and initialized.

Write code that causes a "triangle" of asterisks of size
n to be output to the screen. Specifically, n lines should
be printed out, the first consisting of a single asterisk,
the second consisting of two asterisks, the third
consistings of three, etc. The last line should consist of
n asterisks. Thus, for example, if n has value 3, the
output of your code should be
*
**
***
You should not output any space characters.

Hint: Use a for loop nested inside another for loop.

Answers were Sorted based on User's Feedback



Assume that the int variables i and j have been declared, and that n has been declared and ini..

Answer / sreepal

#include<stdio.h>
main()
{
int i,j,n;
printf("Enter the size of Triangle:");
scanf("%d", &n);

for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
}

Is This Answer Correct ?    9 Yes 4 No

Assume that the int variables i and j have been declared, and that n has been declared and ini..

Answer / geetha.s.b

*
**
***

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C C++ Errors Interview Questions

void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....

2 Answers  


full c programming error question based problem

3 Answers   HCL, TCS,


Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.

1 Answers  


write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;

0 Answers  


errors are known as?

3 Answers   EX, State Bank Of India SBI,






I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX

0 Answers  


what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }

4 Answers  


what is meant for variable not found?

3 Answers  


class test { int a; public: test(int b):a(b){} void show(){ cout<<a; } }; void main() { test t1; test t2(5); t1.show(); t2.show(); } }

1 Answers  


Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.

1 Answers   Google,


printy(a=3,a=2)

3 Answers  


which typw of errors ? & how to solve it ?

0 Answers  


Categories