Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a program in c using only loops to print *
* *
* *
*******

Answer Posted / evr

This is the generic code for printing above such pattern. You can print the above pattern for different number of rows by entering different value during run time

#include<stdio.h>
int main()
{
int n, i, j;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
if(i!= n-1)
{
for(j=1;j<=2*n;j++)
{
if(j==n-i || j==n+i)
printf("*");
else
printf(" ");
}
printf("\n");
}
else
for(i=0;i<2*n-1;i++)
printf("*");
return 0;
}

Thank you......

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How a string is stored in c?

1112


When should you use a type cast?

1175


Differentiate between the = symbol and == symbol?

1358


What is the difference between variable declaration and variable definition in c?

1097


How can you be sure that a program follows the ANSI C standard?

1654


How can I implement sets or arrays of bits?

1087


How can I manipulate strings of multibyte characters?

1153


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

1124


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

2022


What do mean by network ?

1210


Where static variables are stored in memory in c?

1050


What is #include conio h?

1053


What is integer constants?

1129


Explain how to reverse singly link list.

1199


What is binary tree in c?

1133