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: 6569

Attachments:

Replies to This Discussion

#include <cstdlib>

#include <iostream>

 

using namespace std;

 

int main(int argc, char *argv[])

{

          int numberitems;

  

          int sum = 0;

    int number;

          int cnt=0;

          int min=0;

          int max=0;

          int mxln=0;

          int mnln=0;

         

 

 

   cout "Please Enter loop limit : ";

   cin >> numberitems;

          cout""endl;

          cout""endl;

 

    for(int i=0;i<numberitems;i++)

    {

        cout "Please Enter Value for index :" i+1endl; +":"  ;

                   cin >> number;

                            

                   if (min==0){min=number;mnln=i+1;}

                   if (number<min){min=number;mnln=i+1;}

                   if (number>max){max=number;mxln=i+1;}

 

        sum=sum+number;

                   cnt=cnt+1;

 

    }

          cout""endl;

          cout""endl;

 

 

    cout"Sum of entered values =  " sumendl;

          cout"Average values = " sum/cntendl;

          cout"Minimum values = "minendl;

          cout"Minimum values entered at Index  "mnlnendl;

          cout"Maximum values = " maxendl;

          cout"Max values entered at Index  "mxlnendl;

          cout""endl;

          cout""endl;

          system("pause");

          return 0;

}

#include<iostream>
using namespace std;
void process(int);
int main()
{
int loopLimit = 0;


cout"Enter loop limit : ";
cin>>loopLimit;

process(loopLimit);

coutendl;
system("PAUSE");
}
void process(int x)
{
int input = 0;
int sum = 0;
int minValue = 0;
int minIndex = 0;
int maxValue = 0;
int maxIndex = 0;

for(int i = 0 ; i<x;i++){ 


cout"Enger Value "i+1" : ";
cin>>input; 
if(i==0)

minValue = input;
maxValue = input;
minIndex = i+1;
}

if( input < minValue)
{
minValue = input;
minIndex = i+1;
}

else if( input > maxValue)
{
maxValue = input;
maxIndex = i+1;
}
sum = sum + input; 


}

cout"Sum of Entered Values : "sumendl;
cout"Average Values : "sum/5endl;
cout"Minimum Value : "minValueendl; 
cout"Minimum Value entered at index at : "minIndexendl; 
cout"Maximum Value : "maxValueendl;
cout"Maximum Value entered at index at : "maxIndexendl; 


}



#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;

}

Help please, why my values Entering coming on new line
Attachments:

Solved Download from the below link :) Don't forget to change coding and adding soe features

Attachments:

good work boss

Thanks Buddy

boht boht thankssss mudssir bhi

and others who help us

Thanks Brother for liking my work

//Solved By Mudassir Boss . Email : mudasir.boss@gmail.com

#include <iostream>
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<Limit)
{
maxival=Limit;
maxivalIndex=i;
}


i++;
}

Average=Sum/limit2;
cout"\n\n";
cout"Sum of entered values = "Sumendl;
cout"Average values = "Averageendl;
cout"Minimum values = "minivalendl;
cout"Minimum value entered at Index "minivalIndexendl;
cout"Maximum values = "maxivalendl;
cout"Maximum values entered at Index "maxivalIndexendl;

system("pause");

}

//smart brain

#include <iostream>
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<Limit)
{
maxival=Limit;
maxivalIndex=i;
}


i++;
}

Average=Sum/limit2;
cout"\n\n";
cout"Sum of entered values = "Sumendl;
cout"Average values = "Averageendl;
cout"Minimum values = "minivalendl;
cout"Minimum value entered at Index "minivalIndexendl;
cout"Maximum values = "maxivalendl;
cout"Maximum values entered at Index "maxivalIndexendl;

system("pause");

}

RSS

Looking For Something? Search Below

Latest Activity

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

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