Search This Blog

Click Banner To Join Our Whatsapp Group

Click Banner To Join Our Whatsapp Group
Click the banner to Join Now

Saturday 25 January 2020

Coding for Class XI Uploaded. Click on the link below to view.


http://wapcplusplus.blogspot.in/p/coding-class-xi.html

//WAP to read marks of 3 students and store them under an array. #include<iostream.h>
#include<conio.h>
void main()
{
     const int size=3;
     float marks[size];
     //    cout<<"Enter marks of student"<<i+1<<"\n";
     for(int i=0; i<size;i++)
     {
           cout<<"Enter marks of student"<<i+1<<"\n";
           cin>>marks[i];
     }
     cout<<"\n";
     for(i=0;i<size;i++)
     cout<<"Marks["<<i<<"]="<<marks[i]<<"\n";
     getch();
}
-----------------------------------------------------------------
/*Program to read prices of 5 goods in an array and then display sum of all the prices, product of all the prices and average of them*/
#include<iostream.h>
#include<conio.h>
void main()
{
     clrscr();
     const size=5;
     double price[5], avg, sum,prod;
     avg=sum=0;
     prod = 1;
     for(int i=0;i<size;++i)
     {
     cout<<"Enter price for "<<i+1<<" goods: "<<"\n";
     cin>>price[i];
     sum+=price[i];
     prod*=price[i];
     }
     avg=sum/5;
     cout<<"Sum of all prices "<<sum<<"\n";
     cout<<"Average of all prices "<<avg<<"\n";
     cout<<"Product of all prices "<<prod<<"\n";
     getch();

}


-----------------------------------------------------------------

/*
WAP to sort an array on N numbers in ascending order.
Avoid duplication of elements.
*/
#include<iostream.h>
#include<conio.h>
void main()
{
     clrscr();
     int A[20], N, i, j, temp;
     cout<<"\nEnter the number of elements:";
     cin>>N;
     for(i=0;i<N;i++)
     cin>>A[i];
     //Bubble sort technique
     for(i=0;i<N;++i)
           for(j=0;j<(N-1)-i; j++)
           if(A[j]>A[j+1])
                {
                     temp=A[j];
                     A[j]=A[j+1];
                     A[j+1]=temp;
                     }
     cout<<"The elements in the array after sorting...";
     for(i=0;i<N;i++)
     {
     cout<<A[i]<<'\t';
     }
     getch();
     }



And many more....

No comments:

Post a Comment