Write a program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
Don't use printf statements;use two nested loops instead.
you will have to use braces around the body of the outer
loop if it contains multiple statements.

Answer Posted / gana

{
int a,b=2,i;
char *s="\0";
for(i=0;i<5;i++)
{
for(a=0;a<5-i;a++)
putch(' ');
for(a=0;a<b;a++)
putch('*');
b+=2;
puts(s);
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why shouldn’t I start variable names with underscores?

627


I need testPalindrome and removeSpace #include #define SIZE 256 /* function prototype */ /* test if the chars in the range of [left, right] of array is a palindrome */ int testPalindrome( char array[], int left, int right ); /* remove the space in the src array and copy it over to the "copy" array */ /* set the number of chars in the "copy" array to the location that cnt points t */ void removeSpace(char src[], char copy[], int *cnt); int main( void ) { char c; /* temporarily holds keyboard input */ char string[ SIZE ]; /* original string */ char copy[ SIZE ]; /* copy of string without spaces */ int count = 0; /* length of string */ int copyCount; /* length of copy */ printf( "Enter a sentence:\n" ); /* get sentence to test from user */ while ( ( c = getchar() ) != '\n' && count < SIZE ) { string[ count++ ] = c; } /* end while */ string[ count ] = '\0'; /* terminate string */ /* make a copy of string without spaces */ removeSpace(string, copy, ©Count); /* print whether or not the sentence is a palindrome */ if ( testPalindrome( copy, 0, copyCount - 1 ) ) { printf( "\"%s\" is a palindrome\n", string ); } /* end if */ else { printf( "\"%s\" is not a palindrome\n", string ); } /* end else */ return 0; /* indicate successful termination */ } /* end main */ void removeSpace(char src[], char copy[], int *cnt) { } int testPalindrome( char array[], int left, int right ) { }

2220


What does c mean before a date?

594


Which programming language is best for getting job 2020?

611


What are the types of c language?

561






List some of the static data structures in C?

765


What are the 5 types of organizational structures?

554


How do you declare a variable that will hold string values?

672


What is logical error?

605


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

607


What is difference between %d and %i in c?

698


Explain 'bit masking'?

657


How reliable are floating-point comparisons?

632


Explain how does flowchart help in writing a program?

636


What are qualifiers in c?

574