1.

Write a programme to print n no. Of stars in a line

Answer» #include<iostream.h>#include<conio.h>void main(){int i,j,k;clrscr();for(i=1; i<=5; i++){for(j=4; j>=i; j--){cout<<" ";}for(k=1; k<=(2*i-1); k++){cout<<"*";}cout<<"\\n";}getch();}<br><pre class="brush: cpp;toolbar: false; gutter: true;">/** C program to print triangle pyramid pattern using **/#include<stdio.h>#include<conio.h>int main() { int i,j,rows; printf("Enter the number of rows\\n"); scanf("%d", &rows); for(i = 1; i <= rows; i++) { /* Prints one row of triangle */ for(j = 1; j <= i; ++j) { printf("* "); } printf("\\n"); } getch(); return 0;}</pre>


Discussion

No Comment Found