1. Duplicate the even numbers. -1

Sample I/O

Array1:- 4,2,24,3,22

Updated Array:- 4,4,2,2,24,24,3,22,22
2. Reverse the array in a region - 1

Sample I/O

Array1:- 4,2,24,3,22,41,21

Enter Region:- 2,5

Update Array:-4,41,22,3,24,2,21


3. Store first the even digits in an array and then odd
digits in same array -2

Sample I/O

Array1:- 4,2,24,3,22,41,21

Array 2:- 4,2,2,4,2,2,4,2,3,1,1
4. Store the count of the digits in all numbers in an array
and print the count. -2

Sample I/O

Array1:- 4,2,9,3,7,41,28

Array 2:- 0,1,1,1,2,0,0,1,1,1

1-1;2-1;3-1;4-2;7-1;8-1;9-1
5. Store all palindrome numbers in to another array -2

Sample I/O

Array1:- 4,22,9,313,7,141,28

Array 2:- 4,22,9,313,141


6. Arrange the array in such a way that odd numbers come
first and then even numbers -1

Sample I/O

Array1:- 4,22,9,313,7,141,28

Update Array1:- 9,313,7,141,4,22,28
7. Store into another array by inserting it in the right
place - 2

Sample I/O

Array1:- 4,22,9,313,7,141,28

Array2:- 4 /4,22 /4,9,22 /4,9,22 ,313 /4,7,9,22 ,313
/4,7,9,22 ,141,313 /

4,7,9,22,28 ,141,313
8. Merge two sorted arrays in a sorted fashion - 3

Sample I/O

Array 1:- 3,6,7,9,11,16

Array 2:- 1,2,5,7,20

Array 3:- 1,2,3,5,6,7,9,11,16,20

9. Upadte the array so that an array element is followed by
its revere - 1

Sample I/O

Array 1:- 13,63,74,9,11,16

Updated Array 1:- 13,31,63,36,74,47,9,9,11,11,16,16

10.Spread the digits of the array in the same array. -1

Sample I/O

Array 1:- 13,63,74,9,11,16

Updated Array 1:-1,3,6,3,74,9,1,1,1,6

11.Shift the boundary of array to have only 2 digit numbers.

Sample I/O

Array 1:- 139,643,74,9,101,126

Updated Array 1:- 13,96,43,74,91,11,26

12.Print the largest occuring digit in an array of N numbers.

Sample I/O

Array 1:- 13,63,74,9,11,16

1 occurs most.

Answers were Sorted based on User's Feedback



1. Duplicate the even numbers. -1 Sample I/O Array1:- 4,2,24,3,22 Updated Array:- 4,4,2,2,2..

Answer / p.venkataramana

1///Program to Duplicate the even numbers
#include<iostream>
using namespace std;
main()
{
int n,i,j;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is :";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<=n;i++)
{
if(a[i]%2==0)
{
n++;
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}

i++;
a[i]=a[i-1];
}
}
cout<<"\n The updated array is:";
for(i=0;i<n-1;i++)
{
cout<<"\t"<<a[i];
}
}
else
cout<<"\n Invalid entry";
}
2.// Program to Reverse the array in the region
#include<iostream>
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i<n;i++)
cout<<a[i];
if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i<x;i++)
{
cout<<"\t"<<a[i];
}
for(i=y;i>=x;i--)
{
cout<<"\t"<<a[i];
}
for(i=y+1;i<=n;i++)
{
cout<<"\t"<<a[i];
}
}
}

else
cout<<"\n Invalid entry";
}

//Reverse the array in the region
#include<iostream>
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i<n;i++)
cout<<a[i];
if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i<x;i++)
{
cout<<"\t"<<a[i];
}
for(i=y;i>=x;i--)
{
cout<<"\t"<<a[i];
}
for(i=y+1;i<=n;i++)
{
cout<<"\t"<<a[i];
}
}
}

else
cout<<"\n Invalid entry";
}
3.//Store the count of the digits in all numbers in an array
and print the count
#include<iostream>
using namespace std;
main()
{
int
n,i,d,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int count[10];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{

while(a[i]!=0)
{

d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
count[0]=count0;
count[1]=count1;
count[2]=count2;
count[3]=count3;
count[4]=count4;
count[5]=count5;
count[6]=count6;
count[7]=count7;
count[8]=count8;
count[9]=count9;
for(i=0;i<10;i++)
{
if(count[i]!=0)
cout<<"\n "<<i<<"-"<<count[i];
}


}
else
cout<<"\n Invalid entry";
}

4. ///Print the largest occuring digit in an array of n numbers
#include<iostream>
using namespace std;
main()
{
int
n,i,j,d,t,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
int b[10];
int e[10];
if(n>0)
{
cout<<"\n Enter the elements into the array:";
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
while(a[i]!=0)
{
d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
b[0]=count0;
b[1]=count1;
b[2]=count2;
b[3]=count3;
b[4]=count4;
b[5]=count5;
b[6]=count6;
b[7]=count7;
b[8]=count8;
b[9]=count9;
for(i=0;i<10;i++)
{
e[i]=b[i];
}
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{
if(b[i]<b[j])
{
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
for(i=0;i<10;i++)
{
if(e[i]==b[0])
cout<<"\n The largest occuring digit is:"<<i;
}
}
else
cout<<"\n Invalid entry";
}

5.//Arrange the array insuch a way that odd numbers come
first and then the even numbers
#include<iostream>
using namespace std;
main()
{
int n,i,j,t,k;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)

{
cout<<"\n Enter the elements into the array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
for(j=i+1;j<n;j++)
{

if(a[j]%2!=0)
{
t=a[j];
a[j]=a[i];
a[i]=t;
i++;
break;
}
for(k=i;k>0;k--)
{
a[k]=a[k-1];
}


}

}

}
cout<<"\n the updated array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
}
else
cout<<"\n Invalid entry";
}
6.//Spread the digits of the array in the same array
#include<iostream>
using namespace std;
main()
{
int n,i,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{
if(a[i]<0)
a[i]=a[i]*-1;
if(a[i]<10)
continue;
while(a[i]>9)
{
n++;
r=a[i]%10;
for(j=n-1;j>i;j--)
{
a[j]=a[j-1];
}
a[i+1]=r;
a[i]=a[i]/10;
}
}
cout<<"\n the updated array is:";
for(i=0;i<n;i++)
{
cout<<"\t"<<a[i];
}
}
else
cout<<"\n Invalid entry";
}

7.//Update the array so that an array element is followed by
its reverse
#include<iostream>
using namespace std;
main()
{
int n,i,p,rev,d,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{

rev=0;
p=a[i];
while(p!=0)
{

d=p%10;
rev=(rev*10)+d;
p=p/10;
}
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}
n++;
i++;
a[i]=rev;
}
cout<<"\n The updated array is:";
for(i=0;i<n;i++)
{
cout<<"\t"<<a[i];
}
}
else
cout<<"\n Invalid entry";
}
8.//Store all palindrome numbers into another array
#include<iostream>
using namespace std;
main()
{
int n,i,j,rev,r,num,m,count=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int b[n];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)

cout<<"\t"<<a[i];
cout<<"\n The updated array is:";
for(i=0;i<n;i++)
{
rev=0;
num=a[i];
while(a[i]!=0)
{
r=a[i]%10;
rev=(rev*10)+r;
a[i]=a[i]/10;
}
if(num==rev)
{
b[count]=num;
count++;
}
}

for(j=0;j<count;j++)
cout<<"\t"<<b[j];

}
else
cout<<"\n Invalid entry";
}
9.//Merge two stored array in a sorted fashion
#include<iostream>
using namespace std;
main()
{
int arr1[20],arr2[20],arr3[40],arr[40],temp;
int i,j,k,t;
int max1,max2;
cout<<"Enter number of elements in the list 1:";
cin>>max1;
cout<<"\n Take the elements in sorted order:\n";
for(i=0;i<max1;i++)
{
cout<<"Enter element"<<" "<<i+1<<":";
cin>>arr1[i];
}

cout<<"\n Enter number of elements in the list 2:";
cin>>max2;
cout<<"\n Take the elements in sorted order:\n";
for(j=0;j<max2;j++)
{
cout<<"Enter element"<<" "<<j+1<<":";
cin>>arr2[j];
}

i=0;
j=0;
k=0;
while((i<max1) && (j<max2))
{
if(arr1[i]<arr2[j])
arr3[k++]=arr1[i++];
else
arr3[k++]=arr2[j++];


}
while(i<max1)
arr3[k++]=arr1[i++];
while(j<max2)
arr3[k++]=arr2[j++];

cout<<"\n List 1:";
for(i=0;i<max1;i++)
cout<<"\t"<<arr1[i];
cout<<"\n List 2:";
for(j=0;j<max2;j++)
cout<<"\t"<<arr2[j];
cout<<"\n Merged list:";
for(k=0;k<(i+j);k++)
{
for(t=0;t<(i+j);t++)
{
if(arr3[k]<arr3[t])
{
temp=arr3[k];
arr3[k]=arr3[t];
arr3[t]=temp;
}
}
}
for(t=0;t<(i+j);t++)
{
if(arr3[t]!=arr3[t+1])

cout<<"\t"<<arr3[t];

}
cout<<"\n";
}










Is This Answer Correct ?    2 Yes 0 No

1. Duplicate the even numbers. -1 Sample I/O Array1:- 4,2,24,3,22 Updated Array:- 4,4,2,2,2..

Answer / p.venkataramana

1///Program to Duplicate the even numbers
#include<iostream>
using namespace std;
main()
{
int n,i,j;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is :";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<=n;i++)
{
if(a[i]%2==0)
{
n++;
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}

i++;
a[i]=a[i-1];
}
}
cout<<"\n The updated array is:";
for(i=0;i<n-1;i++)
{
cout<<"\t"<<a[i];
}
}
else
cout<<"\n Invalid entry";
}
2.// Program to Reverse the array in the region
#include<iostream>
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i<n;i++)
cout<<a[i];
if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i<x;i++)
{
cout<<"\t"<<a[i];
}
for(i=y;i>=x;i--)
{
cout<<"\t"<<a[i];
}
for(i=y+1;i<=n;i++)
{
cout<<"\t"<<a[i];
}
}
}

else
cout<<"\n Invalid entry";
}

//Reverse the array in the region
#include<iostream>
using namespace std;
main()
{
int n,i,x,y,t;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"Enter the numbers:";
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"Enter the positions for which the
array to be reversed from left to right:";
cin>>x>>y;
cout<<"\n the original array is:";
for(i=0;i<n;i++)
cout<<a[i];
if(x>y)
{
t=x;
x=y;
y=t;
}
if(x<1 || y>n)
cout<<"\n Invalid entry";
else
{
for(i=1;i<x;i++)
{
cout<<"\t"<<a[i];
}
for(i=y;i>=x;i--)
{
cout<<"\t"<<a[i];
}
for(i=y+1;i<=n;i++)
{
cout<<"\t"<<a[i];
}
}
}

else
cout<<"\n Invalid entry";
}
3.//Store the count of the digits in all numbers in an array
and print the count
#include<iostream>
using namespace std;
main()
{
int
n,i,d,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int count[10];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{

while(a[i]!=0)
{

d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
count[0]=count0;
count[1]=count1;
count[2]=count2;
count[3]=count3;
count[4]=count4;
count[5]=count5;
count[6]=count6;
count[7]=count7;
count[8]=count8;
count[9]=count9;
for(i=0;i<10;i++)
{
if(count[i]!=0)
cout<<"\n "<<i<<"-"<<count[i];
}


}
else
cout<<"\n Invalid entry";
}

4. ///Print the largest occuring digit in an array of n numbers
#include<iostream>
using namespace std;
main()
{
int
n,i,j,d,t,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
int b[10];
int e[10];
if(n>0)
{
cout<<"\n Enter the elements into the array:";
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
while(a[i]!=0)
{
d=a[i]%10;
if(d==0)
count0++;
if(d==1)
count1++;
if(d==2)
count2++;
if(d==3)
count3++;
if(d==4)
count4++;
if(d==5)
count5++;
if(d==6)
count6++;
if(d==7)
count7++;
if(d==8)
count8++;
if(d==9)
count9++;
a[i]=a[i]/10;
}
}
b[0]=count0;
b[1]=count1;
b[2]=count2;
b[3]=count3;
b[4]=count4;
b[5]=count5;
b[6]=count6;
b[7]=count7;
b[8]=count8;
b[9]=count9;
for(i=0;i<10;i++)
{
e[i]=b[i];
}
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{
if(b[i]<b[j])
{
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
for(i=0;i<10;i++)
{
if(e[i]==b[0])
cout<<"\n The largest occuring digit is:"<<i;
}
}
else
cout<<"\n Invalid entry";
}

5.//Arrange the array insuch a way that odd numbers come
first and then the even numbers
#include<iostream>
using namespace std;
main()
{
int n,i,j,t,k;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)

{
cout<<"\n Enter the elements into the array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
for(j=i+1;j<n;j++)
{

if(a[j]%2!=0)
{
t=a[j];
a[j]=a[i];
a[i]=t;
i++;
break;
}
for(k=i;k>0;k--)
{
a[k]=a[k-1];
}


}

}

}
cout<<"\n the updated array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
}
else
cout<<"\n Invalid entry";
}
6.//Spread the digits of the array in the same array
#include<iostream>
using namespace std;
main()
{
int n,i,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{
if(a[i]<0)
a[i]=a[i]*-1;
if(a[i]<10)
continue;
while(a[i]>9)
{
n++;
r=a[i]%10;
for(j=n-1;j>i;j--)
{
a[j]=a[j-1];
}
a[i+1]=r;
a[i]=a[i]/10;
}
}
cout<<"\n the updated array is:";
for(i=0;i<n;i++)
{
cout<<"\t"<<a[i];
}
}
else
cout<<"\n Invalid entry";
}

7.//Update the array so that an array element is followed by
its reverse
#include<iostream>
using namespace std;
main()
{
int n,i,p,rev,d,j;
cout<<"\n Enter the size of the array:";
cin>>n;
int a[2*n];
if(n>0)
{
cout<<"\n Enter the numbers into the array:";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)
cout<<"\t"<<a[i];
for(i=0;i<n;i++)
{

rev=0;
p=a[i];
while(p!=0)
{

d=p%10;
rev=(rev*10)+d;
p=p/10;
}
for(j=n;j>i;j--)
{
a[j]=a[j-1];
}
n++;
i++;
a[i]=rev;
}
cout<<"\n The updated array is:";
for(i=0;i<n;i++)
{
cout<<"\t"<<a[i];
}
}
else
cout<<"\n Invalid entry";
}
8.//Store all palindrome numbers into another array
#include<iostream>
using namespace std;
main()
{
int n,i,j,rev,r,num,m,count=0;
cout<<"How many numbers do u want to enter:";
cin>>n;
int a[n];
int b[n];
if(n>0)
{
cout<<"\n Enter the numbers:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"\n The original array is:";
for(i=0;i<n;i++)

cout<<"\t"<<a[i];
cout<<"\n The updated array is:";
for(i=0;i<n;i++)
{
rev=0;
num=a[i];
while(a[i]!=0)
{
r=a[i]%10;
rev=(rev*10)+r;
a[i]=a[i]/10;
}
if(num==rev)
{
b[count]=num;
count++;
}
}

for(j=0;j<count;j++)
cout<<"\t"<<b[j];

}
else
cout<<"\n Invalid entry";
}
9.//Merge two stored array in a sorted fashion
#include<iostream>
using namespace std;
main()
{
int arr1[20],arr2[20],arr3[40],arr[40],temp;
int i,j,k,t;
int max1,max2;
cout<<"Enter number of elements in the list 1:";
cin>>max1;
cout<<"\n Take the elements in sorted order:\n";
for(i=0;i<max1;i++)
{
cout<<"Enter element"<<" "<<i+1<<":";
cin>>arr1[i];
}

cout<<"\n Enter number of elements in the list 2:";
cin>>max2;
cout<<"\n Take the elements in sorted order:\n";
for(j=0;j<max2;j++)
{
cout<<"Enter element"<<" "<<j+1<<":";
cin>>arr2[j];
}

i=0;
j=0;
k=0;
while((i<max1) && (j<max2))
{
if(arr1[i]<arr2[j])
arr3[k++]=arr1[i++];
else
arr3[k++]=arr2[j++];


}
while(i<max1)
arr3[k++]=arr1[i++];
while(j<max2)
arr3[k++]=arr2[j++];

cout<<"\n List 1:";
for(i=0;i<max1;i++)
cout<<"\t"<<arr1[i];
cout<<"\n List 2:";
for(j=0;j<max2;j++)
cout<<"\t"<<arr2[j];
cout<<"\n Merged list:";
for(k=0;k<(i+j);k++)
{
for(t=0;t<(i+j);t++)
{
if(arr3[k]<arr3[t])
{
temp=arr3[k];
arr3[k]=arr3[t];
arr3[t]=temp;
}
}
}
for(t=0;t<(i+j);t++)
{
if(arr3[t]!=arr3[t+1])

cout<<"\t"<<arr3[t];

}
cout<<"\n";
}










Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Interview Questions

Is there sort function in c?

0 Answers  


What is a static variable in c?

0 Answers  


develop a breakfast order booking system using Functions, Structures and Arrays. The system is to support the operations shown to the user in the following system’s menu: Welcome to Asim's Restaurant Select an operation? 1 Make a breakfast order 2 Modify existing order 3 Cancel existing order 4 Print Bill 5 Exit Type in your selection (1, 2, 3, 4 or 5): The program will include an array of structures. The structure type is called MenuItem, and the array of structures should be declared as menu[50] to store upto 50 breakfast menu items. The MenuItem structure must have the following 4 data fields (i.e. members): Code, description, unitprice, and quantity. Your program must define at least the following functions: &#61623; Function LoadData(…) that loads the data of breakfast menu items from an input file menu.txt into the array menu. &#61623; Five separate functions to handle the program main menu five tasks shown above. In general, function main() should load the data into the array menu and display the main menu of the above mentioned tasks. Based on the option selected, the corresponding function should be called. Users must make an order before requesting modify, cancel or print order bill (See the given sample run). Here is a more detailed explanation on the above tasks and functions. LoadData(…) Opens the input file menu.txt (you will create it) containing breakfast menu items data (See below) and assign these values to the corresponding array menu structure fields. Assign zero to the quantity field of the loaded menu items. Welcome to Asim's Restaurant Select an operation? 1 Make a breakfast order 2 Modify existing order 3 Cancel existing order 4 Print Bill 5 Exit Type in your selection (1, 2, 3, 4 or 5): MakeOrder(…) This function is called when the user selects option 1 from the main menu. It first displays the breakfast menu items to the user (stored in the array menu) along with all the necessary information (item code, description and unit price). It then requests the user to select an item using the item code (see the sample run). When the user enters an item code number the program should verify the code number and increment the quantity of the selected item in the array menu. Your program should reject invalid item codes and request the user to re-enter the item code or stop the entry. PrintBill(…) This function is called when the user selects option 4 from the main menu. The function displays the breakfast menu items in the breakfast order by printing the values of all MenuItem members of the array menu that have quantity value above zero. Print a nicely formatted bill (See the sample run). CancelOrder(…) This function is called when the user selects option 3 from the main menu. It will cancel the breakfast order by setting the quantity value of all the array menu structures to zero. ModifyOrder(….) This function is called when the user selects option 2 from the main menu. The task of this function is to allow the user to edit an existing breakfast order with two operations: Adding more breakfast items and/or altering the breakfast item that were ordered before (examine the sample program run). Handling Errors and Invalid Input Your program should reply safely to any erroneous situation or input with appropriate message to the user and flow nicely and correctly to the next operation (Examine the sample program run). Additional functions Use of functions is highly recommended for any additional special tasks needed by your solution. Global variables are not allowed except for max array menu size 50. You must pass the needed parameters through functions parameter lists.

0 Answers  


What does != Mean in c?

0 Answers  


What is the use of pragma in embedded c?

0 Answers  






In how much time you will write this c program? Prime nos from 1 to 1000

2 Answers   TCS,


What is an example of structure?

0 Answers  


What is #line in c?

0 Answers  


What is the difference between far and near ?

0 Answers  


write a reverse string to print a stars.(with out using logic) ***** **** *** ** *

2 Answers  


Why do we use null pointer?

0 Answers  


please help me.. how to write a code of this output?? "Enter range number:"10 1 is an odd number 2 is an even numbers 3 in an odd numbers 4 " to 10" "printing all odd numbers:" 1,3,5,7,9 "printing all even numbers:" 2,4,6,8,10 "sum of all odd numbers:25 "sum of all even numbers:30 using a C Programming ARRAY pleas pleas help.. its my project ..please :(

1 Answers  


Categories