Object

Write a program to print your name in a box using a function.

Algorithm

  1. Declare a function void line().
    The Function main
  2. Call the function line().
  3. Write new line.
  4. Write “\xDB\xDB Syed Iftikhar Ahmad \xDB\xDB”.
    • (‘\xDB’ is the code for one filled box)
  5. Write new line.
  6. Call the function line().
  7. Exit.
    Defining the Function void line()
  8. Declare integer variable i.
  9. Repeat FOR i = 1 to 25 by 1.
    • Write “\xDB”.
    • [End of FOR loop.]
  10. Exit.

Flowchart

C++ Source Code

// program 75
#include<iostream>
using namespace std;

void line();

int main()
{
  line();
  cout << "\n\xDB\xDB Syed Iftikhar Ahmad \xDB\xDB\n";
  line();

  return 0;
}

void line()
{
  int i;
  for (i = 1; i <= 25; i++)
    cout << "\xDB";
}

C Source Code

/*program 75*/
#include<stdio.h>

void line(void);
int main()
{
  line();
  printf("\n\xDB\xDB Syed Iftikhar Ahmad \xDB\xDB\n");
  line();
  
  return 0;
}

void line(void)
{
  int i;
  for(i=1; i<=25; i++)
     printf("\xDB");
}

Output

Design a site like this with WordPress.com
Get started