Lab Task











Program

//*screen Buffer size   width 101    height 9008
window size            width 101    height 30*/
#include<iostream>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
using namespace std;
 void gotoxy(short x, short y){
 HANDLE Manipulador;
 COORD Coordenadas;
 Manipulador=GetStdHandle(STD_OUTPUT_HANDLE);
 Coordenadas.X=x;
 Coordenadas.Y=y;
SetConsoleCursorPosition(Manipulador,Coordenadas);
}
int menu();
int sum=0,g=1,kk,hh=1;
class Labtask{
 public:
  int a[10]={1,2,3,4,5,6,7,8,9,10},value[10],sort[10];
  float b[10];
  void Q1(){
   cout<<"\n\nThe output in tabular form :"<<endl;
   for(int i=0;i<10;i++){
    cout<<a[i];
    cout<<endl;
   }
  }
  int Q2(float d);
  int Q3();
  int Q4();
  int Q5(int f);
 void display();
 void displayQ5(int i);
};
int Labtask::Q2(float d){
   sum=sum+d;}
int Labtask::Q3(){
 for(int i=0;i<10;i++){
    cin>>b[i];
   }
}
Labtask::Q4(){
 int temp;
 for(int i=0;i<10;i++){
  cin>>sort[i];
  if(sort[i]<=10||sort[i]>=100)
      {
cout<<"\n Integer should be in the range between 10-100:\n";
cin>>sort[i];
 }
 }
 for(int k=0;k<10;k++)
 {
 for(int j=0;j<10;j++)
 {
 if(sort[j]>sort[j+1])
{
 temp=sort[j];
 sort[j]=sort[j+1];
 sort[j+1]=temp;}}}
 for(int a=0;a<10;a++){

  if(sort[a]==sort[a+1]){
   sort[a]=0;
   sort[a+1]=0;
  }
 }
for(int f=0;f<10;f++)
{
 if(sort[f]!=0)
 cout<<sort[f]<<"\t";
}
}
Labtask::Q5(int f){
for(int i=0;i<g;i++)
 value[i]=f;
}
void Labtask::display(){
 for(int i=0;i<10;i++)
 {
  if(i%2==0)
  cout<<b[i]+5.5;
  else
  cout<<b[i];
  cout<<"\t";
  }}
void Labtask::displayQ5(int i)
{
cout<<i<<"\t"<<value[i]<<"\t";
  kk=value[i];
 for(int h=0;h<kk;h++)
 cout<<"*";
}
Labtask as,ss[10];
int menu()
{
A:
 system("cls");
 int choice,f,h;
float w;
 cout<<"\n\n\t\t\t\t**************Lab Task**************"<<endl;
 cout<<"\t\t*********************************************************************"<<endl;
 cout<<"\t\t\t\t\t\tMain Menu"<<endl;
 cout<<"\t\t*********************************************************************"<<endl;
 cout<<"\t\t\t1)Question 1"<<endl;
 Sleep(200);
 cout<<"\t\t\t2)Question 2"<<endl;
    Sleep(200);
    cout<<"\t\t\t3)Question 3"<<endl;
    Sleep(200);
    cout<<"\t\t\t4)Question 4"<<endl;
    Sleep(200);
    cout<<"\t\t\t5)Question 5"<<endl;
    Sleep(200);
    cout<<"\t\t*********************************************************************"<<endl;
   cout<<"Enter Question #:";
    cin>>choice;
    if(choice==1){
     system("cls");
     cout<<"\n\n\n\t\t\t\t**************Question 1**************"<<endl;
     cout<<" Write a program that declares an integer array of 10 elements.Initialize the array using\n an initializer list. The program then prints the elements of thearray in a tabular form.\n";
      as.Q1();
     cout<<"Press any key to continue...";
     getch();
     menu();
}
else if(choice==2){
     system("cls");
     cout<<"\n\n\n\t\t\t\t**************Question 2**************"<<endl;
     cout<<" Write a program that declares an integer array of size 10 and scans the values of array\n elements from user. It then calculates the sum of all the elements of the array.";
     cout<<"\n\nEnter 10 elements:"<<endl;
     for(int i=0;i<10;i++){
  cin>>w;
 ss[i].Q2(w);}
 cout<<"sum of array:"<<sum<<endl;
 cout<<"Press any key to continue...";
 getch();
 menu();
 }
else if(choice==3){
     system("cls");
     cout<<"\n\n\n\t\t\t\t**************Question 3**************"<<endl;
     cout<<" Write a program that declares a float array of size 10 and scans the values of array elements\n from user. It then adds a value of 5.5 to even indexed elements and prints the array\n on screen.";
     cout<<"\n\nEnter 10 elements in float:"<<endl;
     as.Q3();
     cout<<"Answer:"<<endl;
     as.display();
      cout<<"\nPress any key to continue...";
    getch();
menu();
 }
else if(choice==4){
     system("cls");
     cout<<"\n\n\n\t\t\t\t**************Question 4**************"<<endl;
cout<<"\n Use an integer array to solve the following problem. Read in 10 numbers,\neach of which is between 10 and 100, inclusive. As each number is read,\nvalidate it and store it in the array only if it is not a duplicate of a number\nalready read. After reading all the values, display only the unique values that\nthe user entered. ";
     cout<<"\n\n Integer should be in the range between 10-100:\n";
    as.Q4();
 cout<<"\nPress any key to continue...";
 getch();
 menu();
 }
else if(choice==5){
     system("cls");
     cout<<"\n\n\n\t\t\t\t**************Question 5**************"<<endl;
     cout<<"\n Integer should be in the range between 0-20:\n";
     for(int i=0;i<10;i++){
     cin>>f;
     if(f>0&&f<20)
     ss[i].Q5(f);
     else{
     cout<<"\n Integer should be in the range between 0-20:";
     cin>>f;
     ss[i].Q5(f);
  }
  g++;
    }
    cout<<"Element\tValue\tHistogram"<<endl;
   for(int j=0;j<10;j++){
    ss[j].displayQ5(j);
    cout<<endl;   }
cout<<"\nPress any key to continue...";
 getch();
 menu();
 }
 else{
  cout<<"wroung input:\nPLEASE WAIT.......";
  Sleep(200);
  goto A;
 }
 }
int main(){
 char a=177 ,b=219;
 system("color f1");
 for(int i=0;i<81;i++)
cout<<char(219);
gotoxy(4,2);
cout<<"Dr. A. Q. Khan Institute of Computer Sciences and Information Technology\n"<<endl;
gotoxy(1,5);
for(int i=0;i<80;i++)
cout<<char(219);
for(int i=1;i<19;i++)
{
gotoxy(0,i);
cout<<char(219);
}
gotoxy(4,9);
cout<<"Topic:";
gotoxy(8,10);
cout<<"Lab Task(week 1)";
gotoxy(4,11);
cout<<"Name:";
gotoxy(8,12);
cout<<"Qazi Khalid Amin";
gotoxy(4,13);
cout<<"Roll #:";
gotoxy(8,14);
cout<<"UET-BSCS-18F-KICSIT-41";
for(int i=1;i<19;i++)
{
gotoxy(80,i);
cout<<char(219);
}gotoxy(1,18);
for(int i=0;i<80;i++)
cout<<char(219);
cout<<"\nPress any key to continue...";
getch();
system("cls");
  cout<<"\n\n\n\t\t\t\tloading Lab Task.....";
  cout<<"\n\n\n";
  cout<<"\t\t\t\t";
    for(int i=0;i<=25;i++)
cout<<a;
  Sleep(200);
  cout<<"\r";
  cout<<"\t\t\t\t";
   for(int i=0;i<=25;i++){
  cout<<b;
  Sleep(200);}
 menu();
}

display





VEDIO:


Comments

Popular posts from this blog

Stack

Operation on Single Linked List

EXTRA INFORMATION ABOUT TECHNOLOGY