Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Assignment No.  1
Semester: Fall 2015

CS201 – Introduction to Programming

 

Total Marks: 20

 

Due Date:

December 01, 2015

 

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/ to from students).

 

Software allowed to develop Assignment

-          Dev C++

 

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.

 

Assignment

 

Task 1: [Marks = 05]

 

Adobe Connect Lab Session Participation Marks (Already completed)

 

Task 2: [Marks = 15]

 

Write a c++ program that initially takes an integer value from the user as the loop’s limit. It means that the loop will execute the same times as the input from the user. The loop will then take integervalues as input from the user until it reaches loop limit.

You are required to use only one variable which will be used to take input repeatedly from the userinside the loop. It means you are not allowed to use the array or multiple variables for this purpose. After that your program will calculate sum of entered values, their average, minimum and maximumvalues along with position on which these values were entered.

 

NOTE: You can use different variables for storing the values for sum, average, minimum and maximum numbers etc. The restriction of using a single variable is just for getting input repeatedly inside the loop.

 

Marks distribution:

 

  • Ø 7 Marks for using only one variable for getting input values within loop
  • Ø 1 Mark  for calculating sum and average of entered values
  • Ø 2 Marks for identifying Minimum and Maximum values
  • Ø 3 Marks are for keeping track and printing the positions/indexes of minimum and maximum values
  • Ø 2 Marks to follow the sample output (Sample output screen is attached below)

 

Sample output screen is provided below; [You are required to follow same output pattern as provided]

 

 

 

 

Deadline:

Your assignment must be uploaded on or before December 01, 2015. We will not accept your solution through email after the due date.

Views: 6531

Attachments:

Replies to This Discussion

can anyone please tell me  if the user enters limit "0"

in that case the average is not correct

shouldn't we include that situation in the code as well?

or i just have to stick with the image limit of "5" ?

dear students some change,s in variable do not copy past

Attachments:

Dear Your programe have many Errors :) Please check

#include <iostream>
using namespace std;
main()
{
//Declaring Variables
int sum,avg,mininum,maxinum,mininumindx,maxinumindx,limit,limitinput;
sum = 0;
avg = 0;
mininum = 0;
maxinum = 0;
mininumindx = 0;

int i = 1;


cout"Enter Loop limit: ";
cin>>limitinput;
cout"\n\n";


limit = limitinput;

while(i<=limit)
{

switch(i){


case 1:
if(i<=limit)
{
cout"Enter "i "st value: ";
cin>>limitinput;
sum+=limitinput;



if(i==1)
{
mininum=limitinput;
maxinum=limitinput;
mininumindx=1;
maxinumindx=1;
}

if(mininum>limitinput)
{
mininum=limitinput;
mininumindx=i;
}

if(maxinum<limitinput)
{
maxinum=limitinput;
maxinumindx=i;
}
i++;
};
case 2:
if(i<=limit)
{
cout"Enter "i "nd value: ";
cin>>limitinput;
sum+=limitinput;



if(i==1)
{
mininum=limitinput;
maxinum=limitinput;
mininumindx=1;
maxinumindx=1;
}

if(mininum>limitinput)
{
mininum=limitinput;
mininumindx=i;
}

if(maxinum<limitinput)
{
maxinum=limitinput;
maxinumindx=i;
}
i++;
};
case 3:

if(i<=limit)
{
cout"Enter "i "rd value: ";
cin>>limitinput;
sum+=limitinput;



if(i==1)
{
mininum=limitinput;
maxinum=limitinput;
mininumindx=1;
maxinumindx=1;
}

if(mininum>limitinput)
{
mininum=limitinput;
mininumindx=i;
}

if(maxinum<limitinput)
{
maxinum=limitinput;
maxinumindx=i;
}
i++;
};
}

if(i<=limit)
{
cout"Enter "i "th value: ";
cin>>limitinput;
sum+=limitinput;



if(i==1)
{
mininum=limitinput;
maxinum=limitinput;
mininumindx=1;
maxinumindx=1;
}

if(mininum>limitinput)
{
mininum=limitinput;
mininumindx=i;
}

if(maxinum<limitinput)
{
maxinum=limitinput;
maxinumindx=i;
}
i++;
}
}

avg=sum/limit;
cout"\n\n";
cout"Sum of entered values = "sum"\n";
cout"Average values = "avg"\n";
cout"Minimum values = "mininum"\n";
cout"Minimum value entered at Index "mininumindx"\n";
cout"Maximum values = "maxinum"\n";
cout"Maximum values entered at Index "maxinumindx"\n";

system("pause");

}

Please Dear Students Must change the varialbe names and also Add some features in thi programme

#include <iostream>
using namespace std;
main ()
{
int limit=0;
int number=0;
int sum=0;
int min=0;
int max=0;
int minIndex=0;
int maxIndex=0;
int average=0;

cout"Please enter the loop limit: ";
cin>>limit;
cout"\n\n";

for (int x=1; x<=limit; x++)
{
cout"Please enter " x" value: ";
cin>>number;
sum = sum+number;

if(x==1)
{
min=number;
max=number;
}
if (min>number)
{
min=number;
minIndex=x;
}
if(max<number)
{
max=number;
maxIndex=x;
}
}
average= sum/limit;
cout"\n\n";
cout"Sum of Entered Values = "sumendl;
cout"Average of the Entered Values = "averageendl;
cout"Minimum Entered Value = "minendl;
cout"Minimum Value Entered at Index = "minIndexendl;
cout"Maximum Entered Value = "maxendl;
cout"Maximum Entered Value at Index = "maxIndex;

}

THis one is wrong :) actualy it's taking two variables as input :) 

Friends here is solution of cs 201 assignment # 1 december 2015 (complete code working)

#include 
using namespace std;
main()
{

int Sum=0; 
int Average=0;
int Limit=0;
int minival=0;
int maxival=0;
int minivalIndex=0;
int maxivalIndex=0;
int limit2 = 0;
int i = 1;

cout"Enter Loop limit: "; cin>>Limit;
cout"\n\n"; limit2 = Limit; while(i<=limit2) { cout"Enter "i>< "value:="" ";="" cin="">>Limit;
Sum=Sum+Limit;

if(i==1)
{
minival=Limit;
maxival=Limit;
minivalIndex=1;
maxivalIndex=1;
}

if(minival>Limit)
{
minival=Limit;
minivalIndex=i;
}

if(maxival

do we have to submit zip folder containing both the snap shot n cpp file?

only .cpp file.

How many bytes will the pointer intPtr of type int move in the following statement?
intPtr += 3 ;


► 3 bytes


► 6 bytes

► 12 bytes

► 24 bytes

► 12 bytes

RSS

Looking For Something? Search Below

Latest Activity

Shaaz WahCantt replied to Mr Siren Head's discussion Ning Chats
15 hours ago
Mr Siren Head replied to Mr Siren Head's discussion Ning Chats
17 hours ago
M. Haris left a comment for Sana rajput
20 hours ago
M. Haris left a comment for Sana rajput
20 hours ago
M. Haris liked Sana rajput's profile
20 hours ago
M. Haris liked MUSFIRA's profile
20 hours ago
M. Haris liked MUSFIRA's profile
20 hours ago
MUSFIRA replied to Mr Siren Head's discussion Ning Chats
21 hours ago

VIP Member Badge & Others

How to Get This Badge at Your Profile DP

------------------------------------

Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service