Pages

Tuesday, 21 August 2018

Program in C to print different types of structure

For printing this type structure in C:

* * * * * 
* * * * * 
* * * * * 
* * * * * 
* * * * * 

Here as we seen the figure is in row and column form thus we have to declare two variable ( i and j ) for row and column respectively. Here we use for loop statement of c.

/* program to print structure */
#include<stdio.h>
void main()
{
int i,j,n ;
clrscr () ;
printf ("\n Enter number of rows:") ;
scanf ("%d", &n) ;
for (i=1;i<=n;i++)
{
for (j=1;j<=n;j++)
{
printf ("*") ;
printf ("  ") ;
}
printf ("\n") ;
}
getch () ;
}

Output screen :: 

Enter number of rows :: 5

output :: 
            
* * * * * 
* * * * * 
* * * * * 
* * * * * 
* * * * * 

For printing this type structure in C:


* *
* * *
* * * *
* * * * *
* * * * * *


Here as we seen the figure is in row and column form thus we have to declare two variable ( i and j ) for row and column respectively. Here we use for loop statement of c.

/* program to print structure */
#include<stdio.h>
void main()
{
int i,j,n ;
clrscr () ;
printf ("\n Enter number of rows:") ;
scanf ("%d", &n) ;
for (i=1;i<=n;i++)
{
for (j=1;j<=i;j++)
{
printf ("*") ;
printf ("  ") ;
}
printf ("\n") ;
}
getch () ;
}

Both of program have nearly same syntax but there is small change in their column for loop statement in case of first type their condition is for (j=1;j<=n;j++) and in case second we have use for (j=1;j<=i;j++).

Output Screen :: 

Enter number of rows :: 5

output ::



* *
* * *
* * * *
* * * * *












10 comments:

  1. Thanks for sharing it! Due to limited time and a lot of work to do, I’m as a student often face difficulties and problems in terms of using and applying the C programming language. Luckily, I’ve found this service https://www.assignmentexpert.com/programming that helps me a lot. Experts provide me with practical and theoretical description of the c programming language. What I like is that they are accessible 24/7. So, even when I forget about my assignments and recall about them the night before I need to pass them, I can rely on their help. Highly recommend!

    ReplyDelete
  2. Are you searching for a 3 Days Golden Triangle Tour ! Enjoy your tour with an affordable price at Optima Travels. We are always here to help you. For more details reach us instantly.

    ReplyDelete
  3. Hi, I have sent my Java assignment to your email as instructed in your Programming Assignment Help portal. I don’t have much time online and therefore I am requesting you to check it now so that you can give me a quotation. All the details of my assignment are provided and I hope you get me a well-experienced C++ Assignment Help tutor to work on it. Kindly note that deadlines mean everything to me and I don’t expect you to take me rounds about the delivery of the work.

    ReplyDelete
  4. Do you guys give a commission if someone decides to give you clients? I have more than 20 students who are looking for Programming Homework Help. I want to act as a broker between you and them provided we agree that you are going to pay me a certain percentage of the profit. If you prove to be reliable then I will give you a huge number of students because I have access to many of them.Right now I have couple of students looking for C++ Assignment Help.

    ReplyDelete
  5. My advice to this company is one. Please don’t say you deliver timely Matlab assignment help yet some of your writers are too lazy to keep the deadlines. I was very clear that I needed my communications system assignment done within 24 hours and the person I gave the job promised he was going to keep time. Well, guess what, the person delivered the work two days later saying he had an issue with his laptop. I still don’t know what could have happened if I hadn’t been smart enough to lie about my deadline. It saved my life because I was able to hire another Matlab assignment helper for the task and this other person actually delivered the work in just 6 hours.

    ReplyDelete
  6. Hello. Ever since my sister has been taking tuition from your online experts, she has been in praise about your system of teaching students. Her grades have improved too. Please tell me if you offer economics homework help free so that I can think about joining too. I also want to know about your online SAS tutoring since it is very famous in town. Please do not forget to revert to me at the earliest. I am waiting. Thanks.

    ReplyDelete
  7. Excelling in Programming has, however, become a huge challenge for most students of Programming. Just as indicated earlier, being good at Programming requires much practical exposure which most students do not have. Actually, most of the students undertaking Programming in colleges are always encountering the field for the first time and this makes Programming look tough for many.
    So Best Assignment Support offers its services to provide assistance in all the programming languages like as follows
    Python Assignment Help
    Java Assignment Help
    c++ Assignment Help Online
    Matlab assignment help

    ReplyDelete
  8. Car rental in Bhubaneswar may be the perfect option if you wish to enjoy a unique blend of privacy and independence while driving. Car rental in Cuttack is a fantastic service that draws thousands of visitors each year. The cabs are in excellent shape, with a standard interior and plenty of space. Every year, tens of thousands of people visit the area, resulting in a thriving tourism economy. Book a car on rent in Puri with a driver is a must-have if you want to explore every nook and cranny of the city without fuss.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. At aarnâ Finance, we believe in providing effective services to our customers. Our DeFi Asset Management Protocols are developed in a way that helps in generating crypto wealth by fusing the best of data science, the financial prowess of the various experts in the market, and the ever-growing blockchain technology. Our Investment DAO Platform harnesses the potential of Web3 by investing DAOs to democratize and broaden the investment process.

    ReplyDelete