Sunday, 1 February 2015

Program to read single digit element in an array and print horizontal histogram.

//Program to read single digit element in an array and print horizontal histogram.

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],n,i,j,max=0;
clrscr();
cout<<"Enter the no. of element in an array:\n";
cin>>n;
for(i=0;i<n;i++)
{
  cin>>a[i];
  if(a[i]>max)
  max=a[i];
}

for(i=0;i<n;i++)
  {
     for(j=0;j<max;j++)

{
if(j<a[i])
cout<<"* ";
else
cout<<" ";
}
cout<<"\n";

   }
getch();
}

Saturday, 31 January 2015

Program to display the circular shift of an array at Nth position.

//Program to display the circular shift of an array at Nth position.

#include<iostream.h>
#include<conio.h>
void main()
{
 int a[5],temp,n,i,j,b;
 clrscr();
cout<<"Enter the 5 elements in array:";
      for(i=0;i<5;i++)
cin>>a[i];
cout<<"Array elements are:\n";
        for(i=0;i<5;i++)
cout<<a[i]<<" ";
cout<<"\nEnter the position from which you want to shift";
cin>>b;
i=0;j=b;
while(i<j)
{
temp=a[i];
for(i=0;i<4;i++)
a[i]=a[i+1];
a[i]=temp;
i++;
 j--;
}
cout<<"\Now array elements are \n";
for(i=0;i<=5;i++)
cout<<a[i]<<" ";
getch();
 }

Read contacts in iOS using Swift with error handling

Just copy and paste the below code Pre-step before pasting the below code Add below line in AppDelegate.swift file below import statement ...