<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Topics tagged with cs201]]></title><description><![CDATA[A list of topics that have been tagged with cs201]]></description><link>https://community.secnto.com//tags/cs201</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 20:01:16 GMT</lastBuildDate><atom:link href="https://community.secnto.com//tags/cs201.rss" rel="self" type="application/rss+xml"/><pubDate>Invalid Date</pubDate><ttl>60</ttl><item><title><![CDATA[Assignment No.  1 Semester: Fall 2022 CS201 – Introduction to Programming]]></title><description><![CDATA[<p dir="auto">Assignment No.  1 Semester: Fall 2022 CS201 – Introduction to Programming</p>
<p dir="auto"><a href="/assets/uploads/files/1670204680618-fall-2022_cs201_1.docx">Fall 2022_CS201_1.docx</a></p>
]]></description><link>https://community.secnto.com//topic/2333/assignment-no-1-semester-fall-2022-cs201-introduction-to-programming</link><guid isPermaLink="true">https://community.secnto.com//topic/2333/assignment-no-1-semester-fall-2022-cs201-introduction-to-programming</guid><dc:creator><![CDATA[Ayesha Zahid]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 1 Solution and Discussion]]></title><description><![CDATA[https://youtu.be/PAY5DTXtq1A
]]></description><link>https://community.secnto.com//topic/2328/cs201-assignment-1-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2328/cs201-assignment-1-solution-and-discussion</guid><dc:creator><![CDATA[cyberian]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 3 Solution and Discussion]]></title><description><![CDATA[@zaasmi said in CS201 Assignment 3 Solution and Discussion:

Re: CS201 Assignment 3 Solution and Discussion
Assignment No.  3
Semester: Fall 2020
CS201 – Introduction to Programming	Total Marks: 20
Due Date:
29-01-2021
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
o	Assignment is submitted after due date.
o	Submitted assignment does not open or file is corrupt.
o	Assignment is copied (From internet/students).
o	Assignment is not in .cpp format.
Software allowed to develop Assignment

Dev C++

Objectives:
In this assignment, the students will learn:
•	Use of class in programming
•	How to deal with a file in programming
•	How to implement switch statement for Class based functions.
ABC bakery is using a console based inventory management system for the receipt generation purposes. Console application will help the cashier in calculating total price of each item with respect to its price. Menu list will provide Add an item  option to take data about an inventory item, include Item Id, Item name, price and quantity. Relevant data of all items will be displayed on screen with the help of menu option. Quantity amount of items will changeable if user wants to add quantity of an item.
Problem Statement
Write a C++ program to manage the inventory item using your knowledge about file handling and classes. User will manage details of an Inventory item using menu list that will provide three options:
ENTER CHOICE

ADD AN INVENTORY ITEM
DISPLAY FILE DATA
INCREASE QUANTITY

Prompt will show to the user for continue the program after dealing with each option, until user will press a key other than ‘y’.
Instructions to write C++ program:
You will use class “Inventory” to declare inventory data and info
Make “Inventory.txt” file to save inventory item record
“Inventory.txt” file will delete each time when the program will run
“ERROE IN OPENING FILE” will be shown if user not press ‘1’ when program will execute first time.
You will use switch statement to handle different conditions and to perform different actions based on the different actions, that is, choice 1, 2, and 3.
Code structure [ Demonstration]:
You will be using the following class and other functions to  develop the assignment:
class Inventory
{
      private:
              int itemID;
              char itemName[20];
              float itemPrice;
              float quantity;
              float totalPrice;

      public:
             void readItem();
             void displayItem();
             int getItemID() ;
             float getPrice() ;
             float getQuantity() ;
            void updateQuantity(float q);    
};

//Deleting existing file
void deleteExistingFile(){--------}

//Appending item in file
void appendToFille(){------------}

//Displaying items
void displayAll(){------------}

//Increasing Quantity of item
void increaseQuanity(){------------}

Program Output:


User’s prompt when program will execute for the first time.
[image: Rokeghr.png]


When user press ‘1’ ,  It will take data about an inventory item as an input from the user.
[image: wryzxvA.png]


When user press ‘2’, it will read data from “Inventory.txt” file and display record of all inventory items on the screen
[image: hxs7hvH.png]


If user press ‘3’, it will ask to enter Item id against which user want to increase item quantity.
[image: tDlho0s.png]


Now, when the user will press ‘2’, the inventory item record will be shown as:
[image: hQCSrHs.png]


Assignment#3 covers course contents from lecture 17 to 30.
Best of Luck!

#include&lt;iostream&gt;
#include&lt;fstream&gt;
#include&lt;stdio.h&gt;
 
using namespace std;

class Inventory
{
      private:
              int itemID;
              char itemName[20];
              float itemPrice;
              float quantity;
              float totalPrice;
      public:
             void readItem();
             void displayItem();
             int getItemID()   { return itemID;}
             float getPrice()    { return itemPrice;}
             float getQuantity()    { return quantity;}
             void updateQuantity(float q)    
             { 
                  quantity=q;
                  totalPrice = (itemPrice*quantity);
             }
};

//    Getting Item 
void Inventory::readItem(){
    cout &lt;&lt; "Please enter item id: ";
    cin &gt;&gt; itemID;
    cout &lt;&lt; "Please enter item name: ";
    cin.ignore(1);
    cin.getline(itemName,20);
    cout &lt;&lt; "Please enter price: ";
    cin &gt;&gt; itemPrice;
    cout &lt;&lt; "Please enter quantity: ";
    cin &gt;&gt; quantity;
    totalPrice = (itemPrice*quantity);
}

//  Displaying Item
void Inventory::displayItem()
{
    cout &lt;&lt; "Item id:" &lt;&lt; itemID &lt;&lt; "\tItem name:" &lt;&lt; itemName &lt;&lt; "\t ItemPrice:" &lt;&lt; itemPrice &lt;&lt; "\t Quantity:" &lt;&lt; quantity &lt;&lt; "\t TotalPrice:" &lt;&lt; totalPrice &lt;&lt; endl;
}

//  Deleting existing file
void deleteExistingFile(){
    remove("Inventory.txt");
}

//  Appending item in file
void appendToFille(){
     Inventory x;
     x.readItem();
  
     ofstream file;   
     file.open("Inventory.txt",ios::binary | ios::app);

    if(!file){
        cout &lt;&lt; "ERROR WHILE CREATING A FILE!\n";
        return;
    }
    
    file.write((char*)&amp;x,sizeof(x));
    file.close();
    cout&lt;&lt;"Inventory record(s) added sucessfully.\n";
}

//  Displaying items
void displayAll(){
    Inventory x;
    ifstream file;
    file.open("Inventory.txt",ios::binary | ios::in);

    if(!file){
        cout&lt;&lt;"ERROR IN OPENING FILE \n";
        return;
    }
    while(file){
    if(file.read((char*)&amp;x,sizeof(x)))
       x.displayItem();
    }
  file.close();
}

//  Increasing Quantity of item
void increaseQuanity(){
    int itemValue;
    int isFound=0;
    int q;
    Inventory x;
 
    cout&lt;&lt;"Enter item id: \n";
    cin &gt;&gt; itemValue;
 
    ifstream fileRead;
    fileRead.open("Inventory.txt",ios::binary | ios::in);
    
    if(!fileRead){
        cout&lt;&lt;"ERROR IN OPENING FILE \n";
        return;
    }
    
    while(fileRead){    
        if(fileRead.read((char*)&amp;x,sizeof(x))){
            if(x.getItemID() == itemValue){
                cout &lt;&lt; "Add quantity? ";
                cin &gt;&gt; q;
                x.updateQuantity(x.getQuantity() + q); 
                isFound=1;
                break;
            }
        }
    }
    
    if(isFound==0){
        cout&lt;&lt;"Record not found!!!\n";
    }

    fileRead.close();

    deleteExistingFile();

    ofstream fileWrite;
    fileWrite.open("Inventory.txt",ios::binary | ios::app);
    fileWrite.write((char*)&amp;x,sizeof(x));

    fileWrite.close();
    cout &lt;&lt; "Item Quantity updated successfully."&lt;&lt;endl;
}

int main()
{
     char ch;
    
    
     do
     {
      char n;
      
 
      cout &lt;&lt; "ENTER CHOICE\n" &lt;&lt; "1. ADD AN INVENTORY ITEM\n" &lt;&lt; "2. DISPLAY FILE DATA\n" &lt;&lt; "3. INCREASE QUANTITY\n";
      cout &lt;&lt; "Please select a choice: ";
    
      cin &gt;&gt; n;

      switch(n)
      {
          case '1':
            appendToFille();
            break;
          case '2' :
            displayAll();
            break;
          case '3':
          	increaseQuanity();
            break;
           default :
                cout &lt;&lt; "Invalid Choice\n";
                break;
      }
   
  /*    else
      cout&lt;&lt;"Enter integer value only";
      }
 */
     cout &lt;&lt; "Do you want to continue? : ";
     cin &gt;&gt; ch;
 
     }
     while(ch=='Y'||ch=='y');
     
    return 0;
    
    
}


]]></description><link>https://community.secnto.com//topic/2199/cs201-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2199/cs201-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 2 Solution and Discussion]]></title><description><![CDATA[
// CS201 Assignment 2 Solution Spring 2021

#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;
int ShowMatrix()
{
	//main matrix
	int row=2, column=2;
	 int matrix[2][2] = { {8, -4} , {-6, 2}  };
   cout&lt;&lt;"The matrix is:"&lt;&lt;endl;
   for(int i=0; i&lt;row; ++i) {
      for(int j=0; j&lt;column; ++j)
      cout&lt;&lt;matrix[i][j]&lt;&lt;" ";
      cout&lt;&lt;endl;
   }
}
	//Transpose
   int showTranspose ( )
{
   int transpose[2][2], row=2, column=2, i, j;
   int matrix[2][2] = { {8, -4} , {-6, 2}  };
   
   cout&lt;&lt;endl;
   for(i=0; i&lt;row; ++i)
   for(j=0; j&lt;column; ++j) {
      transpose[j][i] = matrix[i][j];
   }
   cout&lt;&lt;"The transpose of the matrix is:"&lt;&lt;endl;
   for(i=0; i&lt;column; ++i) {
      for(j=0; j&lt;row; ++j)
      cout&lt;&lt;transpose[i][j]&lt;&lt;" ";
      cout&lt;&lt;endl;
   }
}
//determenent calculating
int	calculateDeterminant()
{

	int  determMatrix[2][2],	determinant;
	int matrix[2][2] = { {8, -4} , {-6, 2}  };
	
	
	
	determinant = ((matrix[0][0] * matrix[1][1]) - 
					(matrix[0][1] * matrix[1][0]));

 	cout &lt;&lt; "\nThe Determinant of 2 * 2 Matrix = " &lt;&lt; determinant;	
}


//Adjoint of matrix
int showAdjoint()
{
	  int ch,A2[2][2] = {{8,-4},{-6,2}},AD2[2][2],C2[2][2];

        
//Calculating co-factors of matrix of order 2x2
        C2[0][0]=A2[1][1]; C2[0][1]=-A2[1][0]; C2[1][0]=-A2[0][1]; C2[1][1]=A2[0][0];
//calculating ad-joint of matrix of order 2x2
        AD2[0][0]=C2[0][0]; AD2[0][1]=C2[1][0]; AD2[1][0]=C2[0][1]; AD2[1][1]=C2[1][1];
        cout&lt;&lt;"\n\nAdjoint of A is :- \n\n";
        cout&lt;&lt;"|\t"&lt;&lt;AD2[0][0]&lt;&lt;"\t"&lt;&lt;AD2[0][1]&lt;&lt;"\t|\n|\t"&lt;&lt;AD2[1][0]&lt;&lt;"\t"&lt;&lt;AD2[1][1]&lt;&lt;"\t|\n";

	
}

int main()
{
	int cho = 0;
	
	cout&lt;&lt;"        ||---Enter your choice---||"&lt;&lt;endl;
	cout&lt;&lt;""&lt;&lt;endl;
	cout&lt;&lt;"---Press 1 to display the matrix and its transpose---"&lt;&lt;endl;
		cout&lt;&lt;"---Press 2 to find adjoint and determinant of the matrix---"&lt;&lt;endl;
		cout&lt;&lt;""&lt;&lt;endl;
		cout&lt;&lt;"Press any other key to exit.";
		cout&lt;&lt;""&lt;&lt;endl;

		cin&gt;&gt;cho;
  
  if (cho ==1)

  	{
  	
  	ShowMatrix();
    showTranspose ( );
	}
    else if (cho == 2)
    {
	
    showAdjoint();
	
	calculateDeterminant();
	}
	else
	
	system("pause");
}




]]></description><link>https://community.secnto.com//topic/2112/cs201-assignment-2-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/2112/cs201-assignment-2-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 3 Solution and Discussion]]></title><description><![CDATA[CS201 ASSIGNMENT 3 SOLUTION SPRING 2021
#include &lt;iostream&gt;
using namespace std;
#define PI 3.14159265

class Circle

{
	private:
		double radius;
	public:
		void setRadius(); 
		void computeAreaCirc();
		
		Circle();	
		~Circle();
};

Circle::Circle()
{
	radius = 0.0;
}

void Circle::setRadius()
{
	
	radius = 5.6;
}

void Circle::computeAreaCirc()
{
	cout &lt;&lt; "Area of circle is: " &lt;&lt; PI * (radius * radius) &lt;&lt; endl;
	
	cout &lt;&lt; "Circumference of circle is: " &lt;&lt; 2 * PI * radius &lt;&lt; endl;

}

Circle::~Circle()
{
	
}

class Rectangle
{
	private:
		double length; 
		double width;
	public:
		void setLength(); 
		void setWidth();
		void computeArea();
		
		Rectangle();
		~Rectangle();
	
};

Rectangle::Rectangle()
{
	length = 0.0;
	width = 0.0;
}

void Rectangle::setLength()
{
	length = 5.0;
	
}

void Rectangle::setWidth()
{
	width = 4.0;
}

void Rectangle::computeArea()
{
	cout &lt;&lt; "Area of Rectangle: " &lt;&lt; length * width &lt;&lt; endl;	
}

Rectangle::~Rectangle()
{
	
}

main()
{
	cout&lt;&lt;"********************SCIENTIFIC CALCULATOR********************"&lt;&lt;endl;
	cout&lt;&lt;""&lt;&lt;endl;
	int run = 1;
	string option, choice;
	
	while(run)
	{
		cout &lt;&lt; "\nOPTION 1 for computing Area and Circumference of the circle" &lt;&lt; endl;
		cout &lt;&lt; "OPTION 2 for computing Area of the Rectangle" &lt;&lt; endl;
		cout &lt;&lt; "Select your desired option(1-2): ";
		cin &gt;&gt; option;
		
		if(option == "1")
		{
			Circle nCircle;
			nCircle.setRadius();
			nCircle.computeAreaCirc();
			cout &lt;&lt; "Do you want to perform anyother calculation(Y/N):";
			cin &gt;&gt; choice;
			if(choice == "Y" || choice == "y")
			{
				continue;
			}
			
			else
			{
				break;
			}
			
		}
		else if(option == "2")
		{
			Rectangle nRectangle;
			nRectangle.setLength();
			nRectangle.setWidth();
			nRectangle.computeArea();
			cout &lt;&lt; "Do you want to perform anyother calculation(Y/N):";
			cin &gt;&gt; choice;
			if(choice == "Y" || choice == "y")
			{
				continue;
			}
			else
			{
				break;
			}
		}
		else
		{
			cout &lt;&lt; "Invalid Option!, Option should be from (1-2)" &lt;&lt; endl;
		}
	}
}


]]></description><link>https://community.secnto.com//topic/1995/cs201-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1995/cs201-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 2 Solution and Discussion]]></title><description><![CDATA[@zaasmi said in CS201 Assignment 2 Solution and Discussion:

code please?

#include&lt;iostream&gt;
using namespace std;

// Declaration of function showElements
void showElements(long s[][4]);
// Declaration of function PercentageDeath
void PercentageDeath(long s[][4], int i);
// Declaration of function PercentageRecovered
void PercentageRecovered(long s[][4], int i);

main()
{
	cout&lt;&lt;"\n\nCS201 Assignment No. 2 Solution \n\n";
	long source_data[7][4]= {0,560433, 22115, 32634, 1,156363, 19899, 34211, 2,84279, 10612, 0, 3,82160, 3341, 77663, 4,71686, 4474, 43894, 5,56956, 1198, 3446, 6,5374, 93, 109};
	showElements(source_data);	
	int user_choice;
	do
	{
		cout&lt;&lt;"\nPress the country code to calculate percentage of dead and recovered persons\n";
		cout&lt;&lt;"\n*** Press 0 for Pakistan ***";
		cout&lt;&lt;"\n*** Press 1 for China ***";
		cout&lt;&lt;"\n*** Press 2 for Italy ***";
		cout&lt;&lt;"\n*** Press 3 for UK ***";
		cout&lt;&lt;"\n*** Press 4 for Iran ***";
		cout&lt;&lt;"\n*** Press5 for France ***";
		cout&lt;&lt;"\n*** Press 6 for Turkey ***";
		cout&lt;&lt;"\n*** Press 7 to Exit ***";	
		cout&lt;&lt;"\n\nPlease select an option use number from 0 to 7 : ";
		input:
		cin&gt;&gt;user_choice;
		if(user_choice&gt;=0 &amp;&amp; user_choice&lt;=6)
		{
			PercentageDeath(source_data, user_choice);
			PercentageRecovered(source_data, user_choice);
		}
		else if(user_choice&lt;0 || user_choice&gt;7) 
		{
			cout&lt;&lt;"\n\nChoice should be between 0 to 7 ";
			cout&lt;&lt;"\ninvalid choice ! please select again : ";
			goto input;	
		}
	}while(user_choice!=7);
}

// definition of function showElements
void showElements(long s[][4])
{
	cout&lt;&lt;"Source Data : \n\n";
	cout&lt;&lt;"Country\tCases\tDeaths\tRecovered\n\n";
	for(int i=0; i&lt;7; i++)
	{
		for(int j=0; j&lt;4; j++)
		{
			cout&lt;&lt;s[i][j]&lt;&lt;"\t";
		}
		cout&lt;&lt;"\n";
	}
}

// definition of function PercentageDeath
void PercentageDeath(long s[][4], int i)
{
	float d_rate=(float)100*s[i][2]/s[i][1];
	cout&lt;&lt;"\nPercentage of death is "&lt;&lt;d_rate;
}

// definition of function PercentageRecovered
void PercentageRecovered(long s[][4], int i)
{
	float r_rate=(float)100*s[i][3]/s[i][1];
	cout&lt;&lt;"\n\nPercentage of recocered is "&lt;&lt;r_rate&lt;&lt;"\n";
}




]]></description><link>https://community.secnto.com//topic/1932/cs201-assignment-2-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1932/cs201-assignment-2-solution-and-discussion</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 1 Solution and Discussion]]></title><description><![CDATA[#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
using namespace std;

main() {
	int choice = 0, salary = 0;
	float increment = 0.0, tax = 0.0, newsal = 0.0;
	
	cout&lt;&lt;"\n ********* SALARY CALCULATOR *********\n"&lt;&lt;endl;
    cout&lt;&lt;" *************************************\n"&lt;&lt;endl;
	cout&lt;&lt;" ********* Enter 1 for SPS6  *********\n"&lt;&lt;endl;
	cout&lt;&lt;" ********* Enter 2 for SPS7  *********\n"&lt;&lt;endl;
	cout&lt;&lt;" ********* Enter 3 for SPS8  *********\n"&lt;&lt;endl;
	cout&lt;&lt;" ********* Enter 4 for SPS9  *********\n"&lt;&lt;endl;
    
	cout&lt;&lt;" Select a pay scale from the menu: ";
	cin&gt;&gt;choice;
	
	switch(choice){
		case 1:
			salary = 40000;
     		increment = salary * 20/100;
     		newsal = salary + increment;
     		tax = newsal * 3/100;
			break;
		case 2:
			salary = 60000;
     		increment = salary * 15/100;
     		newsal = salary + increment;
     		tax = newsal * 3/100;
			break;
			
		case 3:
			salary = 80000;
     		increment = salary * 10/100;
     		newsal = salary + increment;
     		tax = newsal * 3/100;
			break;
			
		case 4:
			salary = 100000;
     		increment = salary * 5/100;
     		newsal = salary + increment;
     		tax = newsal * 3/100;
			break;
			
		default:
			cout&lt;&lt;" Selected choice is invalid."&lt;&lt;endl&lt;&lt;endl;			
	}
	
	if(choice &gt;= 1 &amp;&amp; choice &lt;=4) {
		cout&lt;&lt;" Initial Salary: "&lt;&lt;salary&lt;&lt;endl;
		cout&lt;&lt;" Incremented Amount: "&lt;&lt;increment&lt;&lt;endl;
		cout&lt;&lt;" Increased Salary: "&lt;&lt;newsal&lt;&lt;endl;
		cout&lt;&lt;" Tax Deduction: "&lt;&lt;tax&lt;&lt;endl;	 
		cout&lt;&lt;" Net Salary: "&lt;&lt;newsal-tax&lt;&lt;endl&lt;&lt;endl;
	}	
	    
	system("pause");
}



]]></description><link>https://community.secnto.com//topic/1773/cs201-assignment-1-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/1773/cs201-assignment-1-solution-and-discussion</guid><dc:creator><![CDATA[cyberian]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 3 Solution and Discussion]]></title><description><![CDATA[Ideas Solution 2:
#include&lt;iostream&gt;

#include&lt;fstream&gt;

#include&lt;stdio.h&gt;




using namespace std;

class Employee{

    private:

        int code;

        char name[20];

        float salary;

    public:

        void read();

        void display();

       

        int getEmpCode()            { return code;}

       

        int getSalary()             { return salary;}

       

        void updateSalary(float s)  { salary=s;}

};







void Employee::read(){

    cout&lt;&lt;"Enter employee code: ";

    cin&gt;&gt;code;

    cout&lt;&lt;"Enter name: ";

    cin.ignore(1);

    cin.getline(name,20);

    cout&lt;&lt;"Enter salary: ";

    cin&gt;&gt;salary;

}







void Employee::display()

{

    cout&lt;&lt;code&lt;&lt;" "&lt;&lt;name&lt;&lt;"\t"&lt;&lt;salary&lt;&lt;endl;

}







fstream file;




void deleteExistingFile(){

    remove("EMPLOYEE.DAT");

}




void appendToFille(){

    Employee    x;

    

    x.read();

    

    file.open("EMPLOYEE.DAT",ios::binary|ios::app);

    if(!file){

        cout&lt;&lt;"ERROR IN CREATING FILE\n";

        return;

    }

    file.write((char*)&amp;x,sizeof(x));

    file.close();

    cout&lt;&lt;"Record added sucessfully.\n";

}




void displayAll(){

    Employee    x;

    

    file.open("EMPLOYEE.DAT",ios::binary|ios::in);

    if(!file){

        cout&lt;&lt;"ERROR IN OPENING FILE \n";

        return;

    }

    while(file){

    if(file.read((char*)&amp;x,sizeof(x)))

        if(x.getSalary()&gt;=10000 &amp;&amp; x.getSalary()&lt;=20000)

            x.display();

    }

  file.close();

}




void searchForRecord(){

    Employee    x;

    int c;

    int isFound=0;




    cout&lt;&lt;"Enter employee code: ";

    cin&gt;&gt;c;







    file.open("EMPLOYEE.DAT",ios::binary|ios::in);

    if(!file){

        cout&lt;&lt;"ERROR IN OPENING FILE \n";

        return;

    }

    while(file){

        if(file.read((char*)&amp;x,sizeof(x))){

            if(x.getEmpCode()==c){

                cout&lt;&lt;"RECORD FOUND\n";

                x.display();

                isFound=1;

                break;

            }

        }

    }

    if(isFound==0){

        cout&lt;&lt;"Record not found!!!\n";

    }

    file.close();

}




void increaseSalary(){

    Employee    x;

    int c;

    int isFound=0;

    float sal;




    cout&lt;&lt;"enter employee code \n";

    cin&gt;&gt;c;







    file.open("EMPLOYEE.DAT",ios::binary|ios::in);

    if(!file){

        cout&lt;&lt;"ERROR IN OPENING FILE \n";

        return;

    }

    while(file){

        if(file.read((char*)&amp;x,sizeof(x))){

            if(x.getEmpCode()==c){

                cout&lt;&lt;"Salary hike? ";

                cin&gt;&gt;sal;

                x.updateSalary(x.getSalary()+sal);

                isFound=1;

                break;

            }

        }

    }

    if(isFound==0){

        cout&lt;&lt;"Record not found!!!\n";

    }

    file.close();

    cout&lt;&lt;"Salary updated successfully."&lt;&lt;endl;

}




void insertRecord(){

    Employee    x;

    Employee newEmp;

    

    newEmp.read();




    fstream fin;

    file.open("EMPLOYEE.DAT",ios::binary|ios::in);

    fin.open("TEMP.DAT",ios::binary|ios::out);




    if(!file){

        cout&lt;&lt;"Error in opening EMPLOYEE.DAT file!!!\n";

        return;

    }

    if(!fin){

        cout&lt;&lt;"Error in opening TEMP.DAT file!!!\n";

        return;

    }

    while(file){

        if(file.read((char*)&amp;x,sizeof(x))){

            if(x.getEmpCode()&gt;newEmp.getEmpCode()){

                fin.write((char*)&amp;newEmp, sizeof(newEmp));

            }

   

            fin.write((char*)&amp;x, sizeof(x));

        }

    }




    fin.close();

    file.close();

    

    rename("TEMP.DAT","EMPLOYEE.DAT");

    remove("TEMP.DAT");

    cout&lt;&lt;"Record inserted successfully."&lt;&lt;endl;

}




int main()

{

     char ch;




     deleteExistingFile();




     do{

     int n;




     cout&lt;&lt;"ENTER CHOICE\n"&lt;&lt;"1.ADD AN EMPLOYEE\n"&lt;&lt;"2.DISPLAY\n"&lt;&lt;"3.SEARCH\n"&lt;&lt;"4.INCREASE SALARY\n"&lt;&lt;"5.INSERT RECORD\n";

     cout&lt;&lt;"Make a choice: ";

     cin&gt;&gt;n;




     switch(n){

          case 1:

            appendToFille();

            break;

          case 2 :

            displayAll();

            break;

          case 3:

            searchForRecord();

            break;

        case 4:

            increaseSalary();

            break;

        case 5:

            insertRecord();

            break;




          default :

                cout&lt;&lt;"Invalid Choice\n";

     }




     cout&lt;&lt;"Do you want to continue ? : ";

     cin&gt;&gt;ch;




     }while(ch=='Y'||ch=='y');

    

    return 0;

}

]]></description><link>https://community.secnto.com//topic/931/cs201-assignment-3-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/931/cs201-assignment-3-solution-and-discussion</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Mid Term Solved Paper]]></title><description><![CDATA[Updated links
CS201 quiz_1. Solved with reference Date 15.5.14. by Masoom Fairy.pdf
CS201- midterm solved mcqs with references by Moaaz and Asad.pdf
CS201-midterm subjectives solved with references by moaaz.pdf
]]></description><link>https://community.secnto.com//topic/824/cs201-mid-term-solved-paper</link><guid isPermaLink="true">https://community.secnto.com//topic/824/cs201-mid-term-solved-paper</guid><dc:creator><![CDATA[Izhar Ahmad]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 1 Solution and Discussion]]></title><description><![CDATA[modules:composer.user_said_in, @cyberian, CS201 Assignment 1 Solution and Discussion

Write a C++ program that performs  the following tasks:
1-Print your name and VU id.
2-Add last 3 digit of your VU id.
3-Display the result of sum on screen.
4-Use if-else statement ::
a)	If sum is odd then print your name using while loop. Number of iterations of while loop should be equal to the sum.
b)	If sum is even then print your VU id using while loop. Number of iterations of while loop should be equal to the sum.
[use remainder operator on sum value to determine the odd and even value for if condition]
For example, suppose the student id is BC123456781. Then by adding last 3 digits of vu id, we get 16 which is an even number. In this case, program should print your VU ID for 16 times using while loop.

// C201 Assignment No: 1 Fall2021 
#include &lt;iostream&gt; 
#include &lt;string&gt; 
using namespace std; 
void printnameid(string studentid, string studentname); 
int calculatelastthreedigits(string studentid); 

int main() 
{
string studentid="bc123456789"; 
string studentname="ZAHID"; 
printnameid(studentid,studentname); 
int TotalLastThreeDigits=calculatelastthreedigits(studentid); 
int counter=1; 
int a,b,c; 
a=6; 
b=4; 
c=0; 
cout&lt;&lt;"Sum of Last Three Numbers ="&lt;&lt;a+b+c; 
cout&lt;&lt;"\n\n"; 
if ( TotalLastThreeDigits % 2 == 0) // Divide by 2 and see if the reminder is zero? then it is even otherwise it is odd number 
{ 
cout &lt;&lt; "the sum is an even value: \n\n"; cout&lt;&lt;"++++++++++++++++++++++++++++++++++++++++++++ \n\n"; while(counter &lt;= TotalLastThreeDigits) 
{ 
cout &lt;&lt; " Iteration: " &lt;&lt; counter &lt;&lt; "\n"; 
cout &lt;&lt; "My student id is:" &lt;&lt; studentid &lt;&lt; "\n"; 
counter++; 
} 
} 
else 
{ 
cout &lt;&lt; "the sum is an odd value: \n\n"; 
while(counter &lt;= TotalLastThreeDigits) 
{ 
cout &lt;&lt; " Iteration: " &lt;&lt; counter &lt;&lt; "\n"; 
cout &lt;&lt; "My name is " &lt;&lt; studentname &lt;&lt; "\n"; 
counter++; 
} 
} 
return 0; 
} 
void printnameid(string studentid, string studentname){ 
cout&lt;&lt;"My name is " &lt;&lt; studentname &lt;&lt; "\n\n\n"; 
cout&lt;&lt;"My student id is:" &lt;&lt; studentid &lt;&lt; "\n\n\n"; 
} 
int calculatelastthreedigits(string studentid) { 
int end=studentid.length(); // Ending point that is total length of string 
int start=end-3; // Starting point 
string lastthreedigits=studentid.substr(start,end); // Trim the last three digits; 
int total=0; 
//Calculate the sum of last three digits 
for ( int index=0; index &lt; lastthreedigits.length(); index++) { 
total += lastthreedigits[index] - '0'; 
} 
return total; // return the total to calling statement. 
} 

]]></description><link>https://community.secnto.com//topic/725/cs201-assignment-1-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/725/cs201-assignment-1-solution-and-discussion</guid><dc:creator><![CDATA[cyberian]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Assignment 2 Solution and Discssion]]></title><description><![CDATA[Ideas Solution Code
#include &lt;iostream&gt;
#include &lt;time.h&gt;
#include &lt;stdlib.h&gt;
using namespace std;

const int rows = 10; 
const int cols = 10;

int selectOption(){
	int choice = 0;	

	cout&lt;&lt;"Press 1 to populate a two-dimensional array with integers from 1 to 100\n";
	cout&lt;&lt;"Press 2 to display the array elements\n";
	cout&lt;&lt;"Press 3 to display the largest element present in the array along with its row and column index\n";
	cout&lt;&lt;"Press 4 to find and show the transpose of the array\n";
	cout&lt;&lt;"Press 5 To Exit\n";	
	
	cout&lt;&lt;"\nPlease select an option, use numbers from 1 to 5: ";
	
	do {
		cin&gt;&gt;choice;
		if(choice &gt;= 1 &amp;&amp; choice &lt;= 5){
			break;
		}
		else {
			cout&lt;&lt;"\nChoice should be between 1 and 5\n";
			cout&lt;&lt;"Invalid choice, please select again: ";
		}
	} while(true);
	cout&lt;&lt;"___________________________________________________\n";
	return choice;	
} // end selectOption function

void populateArray(int data[rows][cols]){
	
	srand(time(0));
	for(int i = 0; i &lt; rows; i++){
		for(int j = 0; j &lt; cols; j++){
			
			data[i][j] = rand() % 100 + 1;			
		}
	}
	cout&lt;&lt;"Array populated sucessfully\n";
} // end of poulateArray function

void showElements(int data[rows][cols]){
	
	for(int i = 0; i &lt; rows; i++){
		for(int j = 0; j &lt; cols; j++){
			
			cout&lt;&lt;data[i][j]&lt;&lt;"\t";
		}
		cout&lt;&lt;endl;
	}	
} // end of showElements function

void showLargestElement(int data[rows][cols]){
	
	int largest = 1, row =0, col = 0;
	
	for(int i = 0; i &lt; rows; i++){
		for(int j = 0; j &lt; cols; j++){
			
			if(data[i][j] &gt; largest){
				largest = data[i][j];
				row = i;
				col = j;
			}
		}		
	}
	cout&lt;&lt;"Largest element is "&lt;&lt;largest&lt;&lt;" which is at row = "&lt;&lt;row+1&lt;&lt;" or index = "&lt;&lt;row&lt;&lt;" and column "&lt;&lt;col+1&lt;&lt;" or index "&lt;&lt;col&lt;&lt;endl;
	
} // end of showLargestElement function

void transposeArray(int data[rows][cols]){
	
	for(int i = 0; i &lt; cols; i++){
		for(int j = 0; j &lt; rows; j++){			
			cout&lt;&lt;data[j][i]&lt;&lt;'\t';
		}		
		cout&lt;&lt;endl;
	}
} // end of transposeArray function

main(){
	
	int choice = 0,  data[rows][cols] = {0};
	
	do{
		choice  = selectOption();
		
		switch(choice){
			case 1:
				cout&lt;&lt;endl;
				populateArray(data);	
				cout&lt;&lt;endl;		
				break;
		
			case 2:
				if(data[0][0] == 0){
					cout&lt;&lt;"\nSorry the array is empty, first populate it by pressing 1 to perform this task"&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;
					continue;
				}
				cout&lt;&lt;endl;
				showElements(data);
				cout&lt;&lt;endl;
				break;
			
			case 3:
				if(data[0][0] == 0){
					cout&lt;&lt;"\nSorry the array is empty, first populate it by pressing 1 to perform this task"&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;
					continue;
				}
				cout&lt;&lt;endl;
				showLargestElement(data);
				cout&lt;&lt;endl;
				break;
			
			case 4:
				if(data[0][0] == 0){
					cout&lt;&lt;"\nSorry the array is empty, first populate it by pressing 1 to perform this task"&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;
					continue;
				}
				cout&lt;&lt;endl;
				transposeArray(data);
				cout&lt;&lt;endl;
				break;		
		}
 	}while(choice != 5);  // end of do-while loop
} // end of main function







]]></description><link>https://community.secnto.com//topic/675/cs201-assignment-2-solution-and-discssion</link><guid isPermaLink="true">https://community.secnto.com//topic/675/cs201-assignment-2-solution-and-discssion</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[CS201 Quiz 2 Solution and Discussion]]></title><description><![CDATA[Qno 1: Function Overloading Mean…
1 ) The name of the function will Remain the same but its behavior may change.


The Name of the Function will not remain same but its bahavior will not be change.


Making a function inline.


Function Name can be change.


Qno 2:  sorry i forget.
Qno 3: For accessing data member we use … operator.


 Plus+.   



 Multiplication*



 Dot.



 Division/.



Qno4: Constructor has…


 No name.



 The same name as of class.



 The same Name as Data Member.



 Return type.



Qno5: Free Function is Avaliable in… header file.


 Conio.h



 Iostream.h



 String.h



 Stdlib.h



Qno6: New operator can Be used for…


 Only integer Data type.



 Only char and integer data type.



 Integer, flot, char and double  data type.



 Dot operator.



Qno7: The Malloc function takes…Arguments.


 Two



 Three



 Four



 One.



Qno8: Macros are categorized into…types.


 One



 Four



 Two



 None of the given options.



Qno9: class can be define as…


 A class include both data member as well as Function to manipulate that data.



 A class include only object,



 A class include both object and structure.



 A class does not include Data member and Function.



Qno10: A class is…


 A built in Function.



 A user Define data type.



 An Array.



 A member function.



]]></description><link>https://community.secnto.com//topic/336/cs201-quiz-2-solution-and-discussion</link><guid isPermaLink="true">https://community.secnto.com//topic/336/cs201-quiz-2-solution-and-discussion</guid><dc:creator><![CDATA[mehwish]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>