CS201 Assignment No 1 Solution Fall 2019 | Virtual Study Solutions

Adsetra Ads

 

CS201 Assignment No 1 Fall 2019

Dear Students, Here we will discuss CS201 - Introduction to Programming Assignment No 1 Solution of Semester Fall 2019. CS201 Assignment Due Date is 14 November 2019. Total Marks are 20. Lectures covered in CS201 Assignment are from 1 to 10. Moreover, Solution Code Preview and Video Explanation have also been added. Previously we shared CS201 Assignment No 2 Solution Fall 2019.

Download CS201 Assignment No 2 Solution Fall 2019


File NameDownload Link
CS201 Assignment No 2 Solution Fall 2019.docx Download


CS201 Assignment No 1 Solution and Discussion Fall 2019
CS201 Assignment No 1 Solution and Discussion Fall 2019

We are here to facilitate your learning and we do not appreciate the idea of copying or replicating solutions. Assignment Solution File has been added. Previously we share
d MGT101 Assignment No 1 Solution Fall 2019

CS201 Assignment Instructions

Please read the following instructions carefully before submitting the assignment:
It should be clear that your assignment will not get any credit if:
  • The assignment is submitted after the due date.
  • The submitted assignment does not open or file is corrupt.
  • The assignment is copied (From the internet/students).

Software allowed to develop CS201 Assignment

  • Dev C++
Also Read: DevC++ Installation and Usage Complete Guidelines

CS201 Assignment Objectives:

To enable students to understand and practice the concepts of:
  • Variables and operators
  • Loops or repetition structures 
  • If-else statements
  • Functions 
  • Random number generation
  • Control random number in a specific range

CS201 Assignment Submission Instructions 

You have to submit only.cpp file on the assignments interface of CS201 at VULMS. Assignment submitted in any other format will not be accepted and will be graded zero marks.

CS201 Assignment Question

Programming is a nice tool that can be used to make our life easier. With the help of programming, we can do many things auto-generated and efficiency. As a programmer first task of this semester is given to you is develop a console-based application for school teachers. This application will auto-generate questions for Grades 1, 2, 3, 4 and 5. Using this application teacher will be able to give different papers to each student. 

Assignment Statement:

Write a menu-based program in C++ that will take input from the user(teacher) and fulfill the following requirements.
  • There should be a menu that allows selecting the grade of the class. 
  • Created questions should be mixed type (addition and subtraction).
  • User will give the number of questions that will be generated for a paper.
  • The ratio of addition and subtraction questions is not fixed. It will random, a paper can have more questions of one type than other. See the sample output screenshot. 
  • Number of minimum and maximum digits in paper of grade 1 will be two.
  • Number of minimum and maximum digits in paper of grade 2 will be three.
  • Number of minimum and maximum digits in paper of grade 3 will be four.
  • Number of minimum and maximum digits in paper of grade 4 will be five.
  • Number of minimum and maximum digits in paper of grade 5 will be six.
  • Screen shot of the required application is given below as a simple output. 
  • Most critical requirement is, the operand (number) on left side of subtraction sign must be larger than the number on right side of sign (operator). This requirement is highlighted in sample screenshot too.
  • In the case of addition operation, the operand (number) on left side of the addition sign can be larger or smaller from the number on right side of sign (operator).  

Solution instructions:

  • Variables, loops, if-else, rand() function with % operator, functions (one which returns value and one which do not return a value) will help you to solve the problem. 
  • Use rand() function to generate a random number. You can control the range of numbers with the help of the modulus (%) operator. 
  • To use rand() function you must include “stdlib.h” header file. 
  • To control the range of random number rand() % N can help, if the value of N will be 100 then range of randomly generated numbers will be 0 to 99. 
  • If you want to control the range of random numbers between 10 to 19 then following formula will help.
  • [10 + rand() % (19 – 10 + 1)]
Sample Output:
CS201 Assignment Sample Output
CS201 Assignment Sample Output


CS201 Assignment No 1 Solution Fall 2019

You can see the Sample Preview of CS201 Assignment No 1 Solution provided by (Virtual Study Solutions) below. Click on Download Button to Download Solution File in Your PC. 

CS201 Assignment No 1 Solution Explained


CS201 Solution Code Preview

#include<iostream>
#include<stdlib.h>
using namespace std;
int minNum=0,maxNum=0;
char rsign ();
void setRange(int);
int generateNumber(int,int);
main() {
 int grade=0,noOfQuestions=0,number1=0,number2=0;
 char sign;
 cout<<"1 : First Grade"<<endl;
 cout<<"2 : Second Grade"<<endl;
 cout<<"3 : Third Grade"<<endl;
 cout<<"4 : Fourth Grade"<<endl;
 cout<<"5 : Fifth Grade"<<endl;
 cout<<endl;
 cout<<"Please select grade, user numbers 1 to 5:  ";
 cin>>grade;

 setRange(grade);

 cout<<"Enter number of questions you want to generate: ";
 cin>>noOfQuestions;
 cout<<endl<<endl;


 for(int i=0; i<noOfQuestions; i++) {
  sign=rsign ();
  number2=generateNumber(minNum,maxNum);
  do {
   number1=generateNumber(minNum,maxNum);
  } while(sign=='-'&&number2>number1);
  cout<<i+1<<".(";
  cout<<number1<<sign<<number2<<") =_____\t";
  if(grade!=5) {
   if((i+1)%3==0) {
    cout<<"\n\n";
   }
  } else {
   if((i+1)%2==0) {
    cout<<"\n\n";
   }

  }
 }
 cout<<endl;
 system("pause");
}
int generateNumber(int min,int max) {
 int number=0;
 number=min+rand()%(max-min+1);
 return number;
}
char rsign (){
 int a=0;
 char b;
 a=rand ()% 2;
 if(a==0){
  b='+';
 }else b='-';
 return b;
}
void setRange(int grade) {
 if(grade==1) {
  minNum=10;
  maxNum=99;
 } else if(grade==2) {
  minNum=100;
  maxNum=999;
 } else if(grade==3) {
  minNum=1000;
  maxNum=9999;
 } else if(grade==4) {
  minNum=10000;
  maxNum=99999;
 } else if(grade==5) {
  minNum=100000;
  maxNum=999999;
 }
}

CS201 Solution Code Output Preview

CS201 Solution Code Output Preview of Fall 2019
CS201 Solution Code Output Preview of Fall 2019


Download
 CS201 Assignment No 1 Solution Fall 2019


File NameDownload Link
 CS201 Assignment No 1 Solution Fall 2019.docx Download

Meanwhile, we recommend you to read:

CS201 Past Papers Collection

Download  [  CS201 Mid Term Papers Solved by Moaaz ]  

Download  [  CS201 Past Mid Term Papers Spring 2019 

Download  [  CS201 Past Mid Term Papers Spring 2017 

If CS201 Assignment No 1 Solution Fall 2019 was helpful. Please Share it with your friends. You can also like our Facebook Page or Subscribe Us on Youtube for Latest Updates about Assignments and Past Papers.

Post a Comment

  1. Sir, I have write this code, but file giving an error which screen shot is pasted at the end of this code. please help me to find out the problem.


    #include
    #include
    using namespace std;
    void menu(){
    cout<<"PLEASE ENTER 1 FOR FIRST GRADE: "<>ch;
    if (ch==1){
    min=minRange(1);
    max=maxRange(1);
    } else if (ch==2){
    min=minRange(2);
    max=maxRange(2);
    }else if (ch==3){
    min=minRange(3);
    max=maxRange(3);
    }else if (ch==4){
    min=minRange(4);
    max=maxRange(4);
    }else if (ch==5){
    min=minRange(5);
    max=maxRange(5);
    }

    cout<<"ENTER NUMBER OF QUESTIONS YOU WANT TO GENERATE:";
    cin>>q;
    cout<secNum){
    cout<<"("<<firstNum<<opr<<secNum<<") = _________________\n\n";
    }else{
    cout<<"("<<secNum<<opr<<firstNum<<") = ________________\n\n";
    }
    }
    serial++;
    }
    }

    ********************************
    D:\Data Folder - Hamdani\MIT\CS201 - Introduction to prog\Assign\collect2.exe [Error] ld returned 1 exit status

    ReplyDelete
  2. try this one


    #include
    #include

    using namespace std;

    void menu(){
    cout<<"1 : First Grade"<>ch;
    if(ch == 1){
    min = minRange(1);
    max = maxRange(1);
    }else if(ch == 2){
    min = minRange(2);
    max = maxRange(2);
    }else if(ch == 3){
    min = minRange(3);
    max = maxRange(3);
    }else if(ch == 4){
    min = minRange(4);
    max = maxRange(4);
    }else if(ch == 5){
    min = minRange(5);
    max = maxRange(5);
    }

    cout<<"Enter number of questions you want to generate: ";
    cin>>q;
    cout< secNum){
    cout<<"("<<firstNum<<opr<<secNum<<") = ________ \t";
    if(ch != 5){
    cout<<"\t";
    }
    }else{
    cout<<"("<<secNum<<opr<<firstNum<<") = ________ \t";
    if(ch != 5){
    cout<<"\t";
    }
    }
    }
    serial++;
    }

    }

    ReplyDelete

 

Top