July 2015

CS401 Assignment no 3 

CS401 Graded Assignment no 3 Computer Architecture & Assembly Language

Download Attachment:


Computer Architecture & Assembly Language (CS401)
Assignment # 3(Graded)
Total marks = 20
                                                                                  Deadline Date = July22, 2015
Please carefully read the following instructions before attempting assignment.
Rules for Marking
It should be clear that your assignment would not get any credit if:
  • The assignment is submitted after the due date.
  • The submitted assignment does not open or file is corrupt.
  • Strict action will be taken if submitted solution is copied from any other student or from the internet.

1)      You should concern the recommended books to clarify your concepts as handouts are not sufficient.
2)      You are supposed to submit your assignment in .ppt or pptxformat. Any other formats like scan images, PDF, zip, rar, doc and bmp etc will not be accepted.
Topic Covered:
  • Display Memory
  • String Instruction
  • Software Interrupt
Note:
No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its closing date.
For any query, feel free to email at:


Question Statement:
You are required to write an assembly language program that prints your FULL NAME along with your VU-ID.
You have to use simple Display Memory addressing instructions and attribute setting mechanism (no need to use any subroutine) to print above in the following pattern.

Write ALLAH Using C++ Program

Aslam o Alaikum Write Allah with c++ Please download the attached file given below Feel free to ask any question related to programming.
How to Write Standard Code in C++. There are infinitely many ways to program computers. Ultimately, it is the choice of the programmer.
This Program will print ALLAH words in C++

Attachments:

You Can Download Solved Final term Papers, Short Notes, Lecture Wise Questions Answers Files, Solved MCQs, Solved Quizzes , Solved Final term Subjective Papers , Solved Final term Objective Papers From This Discussion For Preparation Final term Papers of Fall 2015

Download Solution:

Please note that graded assignment no. 3 of CS201 has been uploaded. Due date to upload solutions is 10-07-2015 (Friday 10-July-2015).
All the instructions to solve the assignment are there in assignment file, so make sure that you read all these instructions and upload your solutions before due date. 
Note:
You need to install Winrar to extract compressed assignment file. You can download Winrar from the following link http://www.rarlab.com/download.htm

For any query related to assignment, contact at: CS201@vu.edu.pk
--
Regards,
Instructor CS201

Solution guidelines
The program should operate in following sequence.
  • Program will prompt the user to enter the file name in current directory.
  • System will show a menu with two options:
    • Protect the file
    • Check security status
  • In case user selects the first option (i.e. protect the file), the system will perform the following steps:
    • Read the file
    • Check if the file is already protected or not.
    • In case if file is not protected, program will protect it by the protection mechanism defined above.
    • If file is already protected, system will display appropriate message and exit.
  • If user selects the second option (i.e. check security status), the system will perform following steps:
    • Read the entire file and if key does not exist (i.e. file is not already protected), program will display the message to protect the file first and display menu.
    • If file is already protected, the system will read the contents along with the already existing key. On the basis of contents read, a new key will be generated. If this new key and the existing one (read from the file) do not match, it means that the contents of protected file are changed and vice versa.

Important note
A text file (data.txt) is attached with assignment, use it for protection checking. Video file (Output-Demo.mp4) of desired function is also attached with assignment. Watch the demo video carefully to understand the required functionality (output) of program. Your program should work as per functionality performing in demo video file. You do not need to send text file with your solution. Just upload .cpp file from your LMS account. For any query related to assignment no. 3 contact us at cs201@vu.edu.pk.
Submission
You are required to submit your solution C++ program through LMS i.e. .cpp file



Download Solution:



Solution:

#include <iostream>
#include <string>
#include <cstring>
#include <fstream>

using namespace std;


int GenerateKey(string file){
 int key = 0;
ifstream myfile(file);
 //int val = 0;
if (myfile.is_open())
{
   string line = "";
   while (getline(myfile, line))
   {
       key += line.length();     
   }
 return key;
}
}
bool findKey(string);

int ProtectFile(string filename){
 int key = GenerateKey(filename);
 string mykey = "%";
 ofstream myfile;
 myfile.open(filename,ios::out |ios::app);
  mykey += to_string(key);
  myfile<<mykey;
 myfile.close();
 return key;
 }
int getfileLength(string);
int GetKey(string);
int displayMenu(string filename){
 bool check = false;
 int key = 0;
 int msg = 1;
  check = findKey(filename);
 int getval = 0;
 cout<<"\nOperations on text file\n";
 cout<<"1. Protect my text file\n";
 cout<<"2. Check Security of my text file\n\n";
 cout<<"Enter your choice (1/2): ";
 cin>>getval;
 if(check == false && getval == 2){
  msg = 1;
 }else if(check == false && getval == 1){

  key = ProtectFile(filename);
  msg =  2;
 }
 else if(check == true && getval == 1){
   //checkForChange();
  msg = 3;
 }
 else if(check == true && getval ==2){
  if( GetKey(filename)==getfileLength(filename)){
   msg = 4;
  }
  else if(getfileLength(filename)!=GetKey(filename)){
   msg = 5;
  }
  
 }
 return msg;
 
}
bool findKey(string filename){
 bool check = false;
 string key = "%";
 string line = "";
  ifstream myfile;
 myfile.open(filename, ios::in);
 size_t pos;
while(myfile.good())
  {
      getline(myfile,line); 
      pos=line.find(key); 
      if(pos!=string::npos) 
        {
            check = true;
            break;
        }
  }
  return check;
}
int getfileLength(string filename){
 ifstream myfile (filename);
 int val = 0;
 int key = 0;string line;
if (myfile.is_open())
{  
   while (getline(myfile, line))
   {
       size_t pos = line.find('%');
       if (pos != string::npos)
       {
           line = line.substr(0,pos);
       }
        val += line.length();
   }
 
}
myfile.close();
   return val;  
}
int GetKey(string filename){
 ifstream myfile (filename);
 int val = 0;
 int key = 0;string line;
if (myfile.is_open())
{
   
   while (getline(myfile, line))
   {
       size_t pos = line.find('%');
       if (pos != string::npos)
       {
           line = line.substr(pos+1);
       }
   }
}
myfile.close();
   return atoi(line.c_str()); 
}
int main(){
 string filename = "";
 int key = 0;
 bool choice = false;
 int msg = 1;
 ifstream myfile;
 cout<<"Enter the name of text file in current directory: ";
 cin>>filename;
 
 myfile.open(filename);
 if(!myfile){
  cout<<"\nSorry the name of file "<<filename<<" you entered is not exist in current directory!";
  return 0;
 }else{
  while(msg == 1){
   msg = displayMenu(filename);
   if(msg == 1)
   cout<<"Your text file is not protected, first protect it by using option \"1\"\n\n";
   if(msg == 2){
    cout<<"\nYour text file is protected now!";
   break;
   }
   else if(msg == 3){
    cout<<"\nYour text file is already protected!";
    break;
   }
   else if(msg == 4){
    cout<<"The content of file are not changed after protection.";
    break;
    
   }else if(msg == 5){
    cout<<"Alert! The content of file are changed after protection.";
    break;
   }
   
  }
  
 }

 cout<<endl;
  system("pause"); 
}


My dev version is 5.6.3. if any Query ask in Comments

CS201 final term solved paper mega File

"Introduction To Programming"

CS201-Mega Collection for Final Term only Solved. CS201 Final Term Solved Past papers (large file). CS201 Introduction to Programming final term solve paperMega solve file for paper in attachment download the attachment.

CS201 final term solved paper attachment:



You Can Download Solved Final term Papers, Short Notes, Lecture Wise Questions Answers Files, Solved MCQs, Solved Quizzes , Solved Final term Subjective Papers , Solved Final term  Objective Papers From This Discussion For Preparation Final term Papers.

You should Also Read :

CS 201 All Past Solved Midterm Papers 2015
CS201 Latest Solved MCQs For Final Term Papers
CS201 Solved Final Term Past Papers Collection

For important helping material related to the subject ( Solved MCQs, Assignments, Short Notes, Solved Past Papers, E-Books, Recommended Books, FAQs, Help & Tutorials , Short Questions Answers & more). You must view all the featured discussion in this subject group.
Financial Accounting - MGT101 VU Video Lectures, Handouts, Power Point Slides, Solved Assignments, Solved Quizzes, Past Papers. MGT101 Handouts VU, MGT101 Past Papers,MGT101 midterm papers, Handouts, Lecture Slides, Assignments, Quiz and MCQs Download.
MGT101-Financial Accounting Attachment:

You Can Download Solved Mid Term Papers, Short Notes, Lecture Wise Questions Answers Files, Solved MCQs, Solved Quizzes , Solved Mid Term Subjective Papers , Solved Mid Term Objective Papers From This Discussion For Preparation Mid Term Papers of Fall 2014
For important helping material related to the subject ( Solved MCQsAssignmentsShort NotesSolved Past Papers, E-Books, Recommended Books, FAQs, Help & Tutorials , Short Questions Answers & more). You must view all the featured discussion in this subject group.