In This Post, Provide Latest CS301 Assignment 1 Solution Fall 2021. Easy to See Correct CS301 Assignment 1 Solution Fall 2021 Download with Proper PDF File.
Please Check Below for Current Latest CS301 Assignment
CS301 Assignment 1 Solution for Fall 2022 Semester - DOWNLOAD
CS301 ASSIGNMENT 1 SOLUTION FALL 2021
Provide by VU Answer
Due Date: 9 Dec 2021
Total Marks: 20
Important Instructions Remember:
Submit only compressed (“.zip”) file which will have code (.cpp) and screenshot image file.
While testing your application and entering the record of the first student, use your VU ID as the name of the student. Take a screenshot of your input which should be showing your VU ID entered as first student name.
Zip your code (.cpp) and screenshot image files and submit “.zip” file from your LMS account.
In Simple Word:
1. Program likhny ky bd apny us program ko run krna h then jb ap run krein tu usmy only apni VU ID enter krein.
2. Enter krny ky bd uska screenshot lykr jismy enter krty huwe apki VU ID show hoti hui nazr ajaye.
3. Then apny program ka code format .cpp m ur screenshot dono ko aik .zip file m krky upload krna h lms per.
.ZIP File and.CPP file ka bi Proper Correct idea in below Files
Code Result Given Below in SS Check Easily
CODE Solution:
#include <iostream>
using namespace std;
//Structure of Node
class student
{
public:
int marks;
string name;
student *link=NULL;
};
student *top = NULL;
bool isempty()
{
if(top == NULL)
return true;
else
return false;
}
//Function to insert an element in stack
void push (int marks ,string name)
{
student *ptr = new student();
ptr->marks = marks;
ptr->name = name;
ptr->link = top;
top = ptr;
cout<<"Student Record SUCCESSFULLY Saved\n\n";
}
//Function to delete an element from the stack
void pop ()
{
if ( isempty() )
cout<<"Stack is Empty\n\n";
else
{
student *ptr = top;
top = top -> link;
delete(ptr);
cout<<"Student deleted Successfully\n";
}
}
void reverse()
{
student *current = top;
student *prev = NULL, *link = NULL;
while (current != NULL)
{
// Store next
link = current->link;
// Reverse current node's pointer
current->link = prev;
// Move pointers one position ahead.
prev = current;
current = link;
}
link = prev;
if ( isempty() )
cout<<"Stack is Empty\n";
else
{
cout<<"Name"<<" "<<"Marks\n"<<"----"<<" "<<"----\n";
for (int i; i<=2;i++){
{ cout<<prev->name<<" "<<prev->marks<<"\n";
prev=prev->link;
}
}
}
}
// Function to Display the stack
void displayStack()
{
if (isempty())
cout<<"Stack is Empty\n";
else
{
student *temp=top;
cout<<"Name"<<" "<<"Marks\n"<<"----"<<" "<<"----\n";
while(temp!=NULL)
{ cout<<temp->name<<" "<<temp->marks<<"\n";
temp=temp->link;
}
cout<<"\n";
}
}
// Main function
int main()
{
int choice, flag=1, value;
string name;
while (choice <5){
cout<<"1. To add a student in Stack."<<endl;
cout<<"2. To remove a Student from Stack."<<endl;
cout<<"3. Display all students of Stack."<<endl;
cout<<"4. Display top 3 positions of students."<<endl;
cout<<"5. Press 5 or any other key to close the program."<<endl;
cout<<""<<endl;
cout<<" Enter your choice (1,2,3,4,5):";
cin>>choice;
switch (choice)
{
case 1:cout<<"Enter Name of Student:";
cin>>name;
cout<<"Enter Marks of Student:";
cin>>value;
push(value,name);
break;
case 2: pop();
break;
case 3: displayStack();
break;
case 4: reverse();
break;
flag=0;
}
}
system("PAUSE");
}
Output Result Screenshot
Download CS301 Assignment 1 Solution Fall 2021 .ZIP Complete File
Download CS301 Assignment 1 Solution Fall 2021 PDF File
Download CS301 Assignment 1 Solution Fall 2021 Word File
Check Also:
Latest All Assignment 1 Solution Fall 2021 in One
PLEASE NOTE:
Don't copy the same answer.
Make sure you can make some changes to your solution file before submitting the copy solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an assignment check your assignment requirement file.
If you need some help and question about files and solutions comment below. We will guide you.
3 Comments
Jab ham 4 press kr k Top 3 positions search krty han to compiler index k hisab se show krwata ha or hamy ye nahi krna, instead hamey ye kaha ha assignment me k agr aap ne 5 students add kie han to un me 3 wo students show hony chahye jin k marks top 3 me hon....
ReplyDeleteUsmy jo top waly students hein unko ik save karwaein ur code m sirf screenshot dena h name ki jaga dont worry
DeleteScreebshot to dena ha but us k sath unhon ne code bhi to check krna ha naa.. "
Deleteye nechy condition di hui ha assignment ki:
Display top 3 positions of students. (Student with highest marks is at first place, other positions are according to same highest marks criteria). "