9.01.2011

1. Design rectangle pyramid

Q. Write a program to generate a following structure?
               
                @@@@@
                @@@@@
                @@@@@
                @@@@@
                @@@@@
               
Ans.   

/* c program for symbol structure*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int num,r,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; num>=r; r++)
 {
  for(c=1; c<=num; c++)
     printf("@");
  printf("\n");
 }
 getch();
 return 0;
}

/************* OUTPUT **************
Enter loop repeat number(rows): 5

                @@@@@
                @@@@@
                @@@@@
                @@@@@
                @@@@@
***********************************/

7 comments:

  1. in this program after getch(); there is a semicolon mistake .. please correct it :)

    ReplyDelete
    Replies
    1. Thanks man for improving C programming Community.

      Delete
  2. Design and develop a program to illustrate a combinational circuit with three inputs x, y, and z, and three outputs A, B and C. If the binary input is 0, 1, 2, or 3; the binary output is one greater than the input. If the binary input is 4, 5, 6, or 7; the binary output is one less than the input

    ReplyDelete
  3. the program is wrong no?
    after printf("@"); there should be a } closing bracket for the 2nd loop and a { and the 2nd for statement or else the output would be like this.
    @
    @
    @
    @
    @
    @
    @
    @
    @
    @
    @
    @
    @

    ReplyDelete
    Replies
    1. No,It is right.After for it only read one statement under for.so it is correct code.

      Delete
    2. #include

      int main()
      {

      int i=6,j;
      for(;i>=1;i--)
      {

      for(j=1;j<=5;j++)
      printf("&");
      printf("\n");
      }
      return 1;
      }

      Delete
  4. write an algorithm, draw a flowchart and develop C program. Create astructure student containing fields for roll no., class, year and total marks. create 10 student and store them in a file ... ple iska ans btao pls.. urgently

    ReplyDelete