Friday, 29 December 2017

Winter break holiday homework

Winter break holiday homework
1. Write C++ Programs for the following questions.
i. Wap to enter a mXn matrix and find the smallest and greatest element of it.
ii. Wap to enter a mXn matrix and make all the elements above the diagonal blank.
iii. Wap to find the sum of n natural numbers starting from a given number by creating a function named fsumz(). The function will receive two integers s, n and print all numbers starting from s to n.
iv. Wap to enter 2 strings and compare them. The program should return 0 if the two strings are equal otherwise returns -1.
v. Wap to enter an array of 10 elements and swap the first and last element of it.
vi. Complete the program of ques no. 26 of page no 323 of chapter no. 11of sumita arora book.

2.  Find the output of the questions starting from the ques no. 11 to 16 of page no 322- 323 of chapter 11 of Sumita arora book.

Thursday, 14 December 2017

Good Morning Students... I am back after a long time... Try this program in your system and see the out put

//Delete the occurrence of a particular no from array and fill it by 0 and then rearrange them
#include<iostream.h>
//#include<stdlib.h>
#include<conio.h>
void main()
{
int a[40],b[40],s,i,j=0,f;
cout<<"\nEnter the total no. of elements in the array : ";
cin>>s;
cout<<"\nEnter the array elements\n";
    for(i=0;i<s;i++)
    {
        cout<<"\nElement no.:"<<i+1<<": ";
        cin>>a[i];
    }
cout<<"\nYou have entered the elements as : \n\n";
       for(i=0;i<s;i++)
    {
           cout<<a[i]<<" ";
    }
cout<<"\n\nEnter the element to be deleted from the array:  ";
cin>>f;
cout<<"\nAfter replacing "<<f<<" by 0 we get\n \n";
    for(i=0;i<s;i++)
    {
         if(a[i]==f) 
         {
          a[i]=0;
         }
    }
    for(i=0;i<s;i++)
    {
           cout<<a[i]<<" ";
    }
 
    for(i=0;i<s;i++)
    {
           if(a[i]==0)
           {
             b[j]=a[i];
             j++;
           }
    }
       for(i=0;i<s;i++)
    {
           if(a[i]!=0)
           {
             b[j]=a[i];
             j++;
           }
    }
cout<<"\n\nAfter rearranging elements we get\n\n";
      for(i=0;i<s;i++)
    {
           cout<<b[i]<<" ";
    }
   
 getch();     
}

Delete the occurrence of a particular no from array and fill it by null

//Delete the occurrence of a particular no from array and fill it by null
#include<iostream.h>
//#include<stdlib.h>
#include<conio.h>
void main()
{
int a[40],s,i,f;
cout<<"Enter the total no. of elements in the array";
cin>>s;
cout<<"Enter the array elements";
    for(i=0;i<s;i++)
    {
        cout<<"Element no.:"<<i+1<<": ";
        cin>>a[i];
    }
cout<<"Enter the element to be deleted from the array: ";
cin>>f;
    for(i=0;i<s;i++)
    {
         if(a[i]==f)
         {
         (char)a[i]=(char)32;
         }
    }
    for(i=0;i<s;i++)
    {
        if(a[i]==(char)32)
        {
           cout<<(char)a[i]<<" ";
        }
        else
        {
           cout<<a[i]<<" ";
        }
    }
 getch();     
}