1 Zolokree

Cs201 Assignment No 1 Solution 2015

the correct code of cs201 assignmentn of ending date 16-2-016 is

#include<iostream>
#define MODEL "HP"
#define ALPHABET 26
#define NUMKEYS 10
#define FUNKEYS 12
using namespace std;

class Keyboard
{
public:
void operator=(const Keyboard &obj1);
Keyboard();
~Keyboard();

private:
string Model;
int Albkeys,Numkeys,Funkeys;
};

Keyboard::Keyboard()
{
Model=MODEL;
Albkeys=ALPHABET;
Numkeys=NUMKEYS;
Funkeys=FUNKEYS;
cout"\nKeyboard Created. "endl;

cout"\nModel "Model;
cout"\nAlbkeys "Albkeys;
cout"\nNumkeys "Numkeys;
cout"\nFunkeys "Funkeysendl;
}

void Keyboard::operator=(const Keyboard &obj1 )
{
Model=obj1.Model;
Albkeys =obj1.Albkeys;
Numkeys =obj1.Numkeys;
Funkeys =obj1.Funkeys;
cout"\nKeyboard is assigned "endl;
}

Keyboard::~Keyboard()
{
cout"\nKeyboard has been Destroyed "endl;
}

int main(void)
{
Keyboard *obj1=new Keyboard();
Keyboard obj2;
obj2=*obj1;

}

CS201 Assignment Instructions:

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

CS201 Assignment Objectives:

To enable students to understand and practice the concepts of:
  • Variables and operators
  • Expressions in C++
  • Decision structures
  • Repetition structures

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.

Software allowed to develop Assignment:

Recommended :DevC++ Installation and Usage Complete Guidelines

CS201 Assignment No 1

Write a program that will Ask the user to enter lower limit and upper limit in the form of integer numbers.
The program will then add / sum all those numbers between upper limit and lower limit (including the lower and upper limits) which are NOT multiple of 4.
This process should continue for all the remaining integer numbers up until the upper limit is reached.
The program will then show the aggregate sum of all numbers for the given range.

Make sure that lower limit entered by the user should be greater than zero. Also the upper limit value entered by the user should be greater than the lower limit value.

Example:
Lower limit is 1 and Upper limit is 8 then the program will subtract 4 and 8 as these are the multiples of 4. While add remaining integers in the range (1+2+3-4+5+6+7-8 = 12). So, 12 is the calculated number.

CS201 Assignment No 1 Solution


#include<iostream>#include<stdlib.h>usingnamespace std; intmain() { int upperlmt, lowerlmt, sum=0,a; cout<<"please enter lower limit greater then zero="; cin>>lowerlmt; if (lowerlmt>0) { cout<<"please enter upper limit greater than lower limit="; cin>>upperlmt; if (upperlmt>lowerlmt) { for(a=lowerlmt; a<=upperlmt; a++) { if(a%4==0) { sum=sum-a; } else { sum=sum+a; } } cout<<"calculated number is="<<sum; } else { cout<<"upper limit must be greater than lower limit"; } } else { cout<<"lower limit should be greater then zero"; } system("pause"); return0; }

Assignment Solution Source Code Output

You can see the Sample output of Cs201 Assignment Solution Source code in image given below. it works fine. Please test it in your compiler before submitting the Assignment.

CS201 Assignment Solution Source Code Sample Output

Leave a Comment

(0 Comments)

Your email address will not be published. Required fields are marked *