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
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 |
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.....
full c programming error question based problem
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.
write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;
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
what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }
what is meant for variable not found?
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(); } }
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.
printy(a=3,a=2)
which typw of errors ? & how to solve it ?