Array Numbers Initialization in C++

Array is a set of values in which we can store multiple values and access them one by one. When we initialize array it contain the garbage values and here in this problem we will remove these garbage values and initialize these values with zero.

Source Code

#include<iostream>
using namespace std;
int main ()
{
  int nums[5];
  cout<<"\t \t \t  LEP Tutorials \n \n \n ";
  cout<<"1. Numbers Without Initialization \n ";
  for (int i =0;i<5;i++)
 {
  cout<<endl;
  cout<<"\t"<<nums[i];
 }
  cout<<endl<<endl;
  cout<<"2. Numbers After Initialization \n ";
  for (int i =0;i<5;i++)
 {
  nums[i] = 0;
  cout<<endl;
  cout<<"\t"<<nums[i];
 }
}

Output of the Program

Array Numbers Initialization in C++

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment