tell me a different program in which function,array,loops and structure are used? i present it on tuesday

How about a program containing a function that creates an array of structures and loops over it?

Edited 2 Years Ago by Moschops

Unfortunately, it's not clear from your question what is the exact processing required.

Please can you specify what you want more clearly - and then show a REAL attempt at answering the question - it's clear to anyone who's done any programming teaching that what you've shown in your question is the answer to some other assignment.

Here I am giving some examples of basic programs that you asked for. Check them out.

// function example
#include <iostream>
using namespace std;

int addition (int a, int b)
{
  int r;
  r=a+b;
  return r;
}

int main ()
{
  int z;
  z = addition (5,3);
  cout << "The result is " << z;

//Array Example

#include <iostream>
using namespace std;

#include <iomanip>
using std::setw;

int main ()
{
   int n[ 10 ]; // n is an array of 10 integers

   // initialize elements of array n to 0          
   for ( int i = 0; i < 10; i++ )
   {
      n[ i ] = i + 100; // set element at location i to i + 100
   }
   cout << "Element" << setw( 13 ) << "Value" << endl;

   // output each array element's value                      
   for ( int j = 0; j < 10; j++ )
   {
      cout << setw( 7 )<< j << setw( 13 ) << n[ j ] << endl;
   }

   return 0;
}

/*  For loop Example            */

#include<iostream>
#include<conio.h>

using namespace std;

int main()
{

     // Variable Declaration
     int a;

     // Get Input Value
     cout<<"Enter the Number :";
     cin>>a;

     //for Loop Block
     for (int counter = 1; counter <= a; counter++)
     {
         cout<<"Execute "<<counter<<" time"<<endl;
     }

     // Wait For Output Screen
     getch();
     return 0;
 }
This article has been dead for over six months. Start a new discussion instead.