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

Attachments:

Replies to This Discussion

#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 is just idea to how to find a smaller number in data. so u will be able to use the core code in your assignment, take idea and make your assignment.
Note:its not solution. contents of codes can be used to make assignment but dont upload as assignment as it can cause deduction of numbers.

#include <iostream.h>

main()
{
int RCV=0;
int Carry[10];
int size=0;
int Indexcount=0;
//to get the number of loops time form user

cout"Enter loop limit:";
cin>>size;
//get the values for use to save in an array
for(int c = 0;c < size;++c){
if(c==0){
cout"Enter the 1st value";
cin>>RCV;
Carry[0]=RCV;};
if(c==1){
cout"\n Enter the 2nd value";
cin>>RCV;
Carry[1]=RCV;};
if(c==2){
cout"\n Enter the 3rd value";
cin>>RCV;
Carry[2]=RCV;};
if(c==3){
cout"\n Enter the 4th value";
cin>>RCV;
Carry[3]=RCV;};
if(c==4){
cout"\n Enter the 5th value";
cin>>RCV;
Carry[4]=RCV;};};
int min;
min=Carry[0];
for(int b=1;b<size;++b)
{
if(Carry[b]<min)
{
min=Carry[b];
Indexcount=b;
//coutminendl;
//coutIndexcountendl;
};};
cout"Minimum vlue is :"minendl;
cout"Index of the value is "Indexcountendl;

// comparision we will with the first value to find minimum value.
system("pause");
}

//ASSIGNMENT SOLUTION BY JERRY

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

}

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.

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

}

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


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

process(loopLimit);

coutendl;

}
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 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");

}

ye ly g

Attachments:

This is complete solved file for all :) .. Please must change its variable names and add some comments .. 

in this I added  1st , 2nd ,3rd and 4th features .. which follows the screen of the assignment programme . 

Attachments:

File is updated please download this new one file

Attachments:

complete n verified solution....avg=22 problem is solved by using ceil function.... copy code from here or just download .cpp ... thnx all sis n bro :)

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int minIndex = 1, maxIndex = 1, values, min = 0, max = 0 ;
    double average, sum, loop;
    cout "Enter Loop limit: ";
    cin>>loop;
    cout endl;
    for(int i=1; i<=loop; i++)
    {
            if(i==1)
            {
                    cout"Enter 1st value; ";
            }
            else if(i==2)
            {
                    cout"Enter 2nd value; ";
            }
            else if(i==3)
            {
                    cout"Enter 3rd value; ";
            }   
            else if(i<=loop)
            {
                    cout"Enter " i "th value; ";
            }  
             cin>> values;
             sum +=values;
             average = ceil(sum/loop);
             if (i==1)
             {
                      min = values;
                      max = values;
                      minIndex = 1;
                      maxIndex = 1;
             }            
             if (min > values)
             {
                     min = values;
                     minIndex = i;
                     
             }
            if (max < values)
            {
                    max = values;
                    maxIndex = i;
            }          
    }
    cout endl endl;
    cout "Sum of Entered Values = " sum endl;
    cout "Average Values = " average endl;
    cout "Minimum Values = " min endl;
    cout "Minimum Value Entered at Index " minIndex endl;
    cout "Maximum Values = " max endl;
    cout "Maximum Value Entered at Index " maxIndex endl;
    system("PAUSE");
    
}

Attachments:

RSS

Looking For Something? Search Below

Latest Activity

+ ! zεε liked иαвєєℓ αнмє∂'s discussion CS619 Project Students
4 hours ago
Hamid left a comment for jiya ali
5 hours ago
Hamid and jiya ali are now friends
5 hours ago
Usama shahid joined + M.Tariq Malik's group
12 hours ago
Yasir Hassan liked + ♥ Haniya Khan's photo
13 hours ago
Profile Iconsria aslam, Khawir Abbas and Sana Shafaq joined Virtual University of Pakistan
16 hours ago
+ ♥ Haniya Khan posted a photo
yesterday
Abdul Rehman updated their profile
Saturday

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