We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

Assignment No. 02 Semester: Spring 2012 CS201: Introduction to Programming Total Marks: 20 Due Date:02/05/2012

Assignment No. 02
Semester: Spring 2012

CS201: Introduction to Programming

Total Marks: 20

 

Due Date:02/05/2012

 

Instructions:

Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:

 

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file is corrupt.
  • Assignment is copied(partial or full) from any source (websites, forums, students, etc)

 

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case.

 

 

Objective:

 

The objective of this assignment is to provide hands on experience of:

 

  • Functions
  • Array Manipulation

 

 

Guidelines:

 

  • Code should be properly indented and well commented.
  • Follow C/C++ rules while writing variable names, function names etc
  • Use only dev-C++ for this assignment.
  • Use appropriate C/C++ structure i.e. if-else; switch statement etc to get inputs from user where required (Marks will be deducted if inappropriate structure will be used)..

 

 

 

 

 

 

 

 

 

Assignment  

 

 

Problem Statement:    Temperature Calculation system    

 

Write a program that displays average, highest and lowest temperatures.

 

Detailed Description:

 

  • The program will take temperature readings as input from user for specified number of consecutive days.
  • Program will store these temperature values into an array.
  • Then it will pass this array to three different functions.
  • One function will return highest temperature, one will return lowest temperature and third one will return average temperature.
  • All these functions will be called inside main() function where these temperature results will be displayed to the user.

 

Sample Output:

 

Enter the number of consecutive days to read their temperature : 5

 

Enter temperature for day 1: 50

 

Enter temperature for day 2: 80

 

Enter temperature for day 3: 30

 

Enter temperature for day 4: 92

 

Enter temperature for day 5: 47

 

The average temperature is 59.80

The highest temperature is 92.00

The lowest temperature is 30.00  

 

 

 

NOTE:

The array containing temperature values must be passed to three different functions to return average, highest and lowest temperatures. Marks will be deducted if assignment is solved with some other technique.

 

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 2733

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

please discus here about the solution of the assignment 

thanks regards

khalid pervez 

Please Discuss here about this assignment.Thanks 

Yesss

ya solution sahee ha ka nahee

CS201 Assignment No 2 Solution Spring 2012

Problem Statement:    Temperature Calculation system    

Write a program that displays average, highest and lowest temperatures.

Detailed Description:

  • The program will take temperature readings as input from user for specifiednumber of consecutive days.
  • Program will store these temperature values into an array.
  • Then it will pass this array to three different functions.
  • One function will return highest temperature, one will return lowesttemperature and third one will return average temperature.
  • All these functions will be called inside main() function where thesetemperature results will be displayed to the user.Enter the number ofconsecutive days to read their temperature : 5Enter temperature for day 1:50Enter temperature for day 2: 80

Enter temperature for day 3: 30

Enter temperature for day 4: 92

Enter temperature for day 5: 47

The average temperature is 59.80

The highest temperature is 92.00 The lowest temperature is 30.00

NOTE:

The array containing temperature values must be passed to three different functions to return average, highest and lowest temperatures. Marks will be deducted if assignment is solved with some other technique.

 

 

Solution:

 

#include <cstdlib>
#include <iostream>

void high_Tenp(int [],int);

void low_Tenp(int []);

void Average_Tenp(int [],int);

using namespace std;

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

cout"\t\t***********************************"endl
"\t\t TEMPRATURE CALCULATION SYSTEM "endl
"\t\t***********************************"endlendl;
int n;

cout"Enter the number of consecutive days to read theirtemperature : ";

cin>>n;

int x[n];

int i, j, tmp;

for(i=0;i<n;i++)
{

coutendl"Enter temperature for day "i+1" : ";

cin>>x[i];

}

for(i=0; i<n; i++)
{

for(j=0; j<n-1; j++)
{

if (x[j] > x[j+1])
{

tmp = x[j];

x[j] = x[j+1];

x[j+1] = tmp;

}

}

}

Average_Tenp(x,n);

high_Tenp(x,n);

low_Tenp(x);

system("pause");

}

void high_Tenp(int a[],int arraysize)
{
cout"The Higest Temprature is : "a[arraysize-1]endl;
}

void low_Tenp(int a[])
{
int b=0;
cout"The Lowest Temprature is : "a[b]endl;
}

void Average_Tenp(int a[],int arraysize)
{
int i;

double c=0;

for ( i = 0 ; i < arraysize ; i ++)
{
c=c+a[i];
}
c=c/i;
coutendl"The Average Temprature is : "cendl;
}

void swap(int *x, int *y) //function using pointers to interchange the values

{

int tmp;

if(*x > *y)

{

tmp = *x;

*x = *y;

*y = tmp;

}

}

CS201+Assignment+No#2+Solution+Spring+2012

See the attached file please

Attachments:
CS201 Assignment No 2 Solution Spring 2012

Problem Statement: Temperature Calculation system 
Write a program that displays average, highest and lowest temperatures.
Detailed Description:

The program will take temperature readings as input from user for specifiednumber of consecutive days.

Program will store these temperature values into an array.
Then it will pass this array to three different functions.
One function will return highest temperature, one will return lowesttemperature and third one will return average temperature.
All these functions will be called inside main() function where thesetemperature results will be displayed to the user.Enter the number ofconsecutive days to read their temperature : 5Enter temperature for 

day 1:50Enter temperature for day 2: 80
Enter temperature for day 3: 30
Enter temperature for day 4: 92
Enter temperature for day 5: 47
The average temperature is 59.80

The highest temperature is 92.00 The lowest temperature is 30.00
NOTE:

The array containing temperature values must be passed to three different functions to return average, highest and lowest temperatures. Marks will be deducted if assignment is solved with some other technique.


Solution:

#include <cstdlib>
#include <iostream>
void high_Tenp(int [],int);
void low_Tenp(int []);
void Average_Tenp(int [],int);
using namespace std;
int main(int argc, char *argv[])
{
cout"\t\t***********************************"endl
"\t\t TEMPRATURE CALCULATION SYSTEM "endl
"\t\t***********************************"endlendl;
int n;
cout"Enter the number of consecutive days to read theirtemperature : ";
cin>>n;
int x[n];
int i, j, tmp;
for(i=0;i<n;i++)
{
coutendl"Enter temperature for day "i+1" : ";
cin>>x[i];
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++)
{
if (x[j] > x[j+1])
{
tmp = x[j];
x[j] = x[j+1];
x[j+1] = tmp;
}
}
}
Average_Tenp(x,n);
high_Tenp(x,n);
low_Tenp(x);
system("pause");
}
void high_Tenp(int a[],int arraysize)
{
cout"The Higest Temprature is : "a[arraysize-1]endl;
}
void low_Tenp(int a[])
{
int b=0;
cout"The Lowest Temprature is : "a[b]endl;
}
void Average_Tenp(int a[],int arraysize)
{
int i;
double c=0;
for ( i = 0 ; i < arraysize ; i ++)
{
c=c+a[i];
}
c=c/i;
coutendl"The Average Temprature is : "cendl;
}
void swap(int *x, int *y) //function using pointers to interchange the values
{
int tmp;
if(*x > *y)
{
tmp = *x;
*x = *y;
*y = tmp;
}
}

tough assig :(

cs201 2nd assignment solution 2012

#include<iostream.h>
#include<conio.h>

void GetAnnualIncome(int[],int);
void CalcIncChange(int[], double[],int);
void CalcChangePercent(int[], double[], float[], int);
void IncDecYears(double[], int);
void MaxIncDecYears(int,int); 

main()
{
int anlIncm[10];
double chngInc[10];
float chngIncPer[10];

cout"\n\n .... ABC Company Income Sheet ....\n"endl;
cout"Enter Income for Past 10 Years (in Millions)\n"endl;
GetAnnualIncome(anlIncm,10);
CalcIncChange(anlIncm, chngInc, 10);
CalcChangePercent(anlIncm, chngInc,chngIncPer, 10);
IncDecYears(chngInc, 10);
coutendlendl; 
system("pause");
}

void GetAnnualIncome(int inc[],int size)
{
int var;
for(int i=0;i<size;i++)
{
cout"Income for Year "2000+i" : ";
cin>>var;
if(var < 0)
{
i--;
}
else if(var >=0 )
{
inc[i] = var;
}
}
}

void CalcIncChange(int inc[], double chg[],int size)
{
cout"\n\n";

chg[0] = inc[0] -1000;
for(int i=1;i<size;i++)
{
chg[i] = inc [i] - inc[i-1];
}
for(int i=0;i<size;i++)
{
if (chg[i] >= 0)
{
cout"Income Increase in Year "2000+i" : "chg[i]"million"endl;
}
else if (chg[i] < 0)
{
cout"Income Decrease in Year "2000+i" : "chg[i]*-1"million"endl;
}
}
}
void CalcChangePercent(int inc[], double chg[], float per[], int size)
{


cout"\n\n";
per[0] = (chg[0]*100 / 1000);
for(int i=1;i<size;i++)
{
per[i] = (chg [i]*100 / inc[i-1]);
}
for(int i=0;i<size;i++)
{
if (per[i] >= 0)
{
cout"Income Increase in Year "2000+i": "per[i]"%"endl;
}
else if (per[i] < 0)
{
cout"Income Decrease in Year "2000+i": "per[i]*-1"%"endl;
}
}
}


void IncDecYears(double chg[], int size)
{
int max, min;
cout"\n\nIncome Increased in the following years: "endl;
for(int i=0;i<size;i++)
{
max=min=0;
if (chg[i] >= 0)
{

if(chg[max] < chg[i])
{
max = i;

cout2000+i", ";
}
}
cout"\n\nIncome Decreased in the following years: "endl;
for(int i=0;i<size;i++)
{
if (chg[i] < 0)
{
if(chg[min] > chg[i])
{
min = i;
}
cout2000+i", ";
}
}
MaxIncDecYears(max+2000,min+2000);



void MaxIncDecYears(int max,int min)
{
cout"\n\nYear with maximium income Increase: "maxendl;
cout"Year with maximium income Decrease: "minendl;

system("pause");
}

Hainnnnnnnnnnnnn :O

ye kesa code ha :P

hahaha

 

void MaxIncDecYears(int,int); error 

on top of the solution they contain certain problem which dev C++ does not debug at..

 int  correct instead of int,int........according to my knowledge 

RSS

Latest Activity

Mushk replied to zohaib iftikhar's discussion ...* KAHAN HAI AB TUMHARI WO MOHABBAT ITNY SAALON KI ...*???
42 minutes ago
Mushk replied to zohaib iftikhar's discussion ...*...*...* DAIKH MAIN TUJH SE KITNA PAYAR KRTA HON??? ...*...*...*
46 minutes ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...* KAHAN HAI AB TUMHARI WO MOHABBAT ITNY SAALON KI ...*???
52 minutes ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...*...*...* DAIKH MAIN TUJH SE KITNA PAYAR KRTA HON??? ...*...*...*
53 minutes ago
Mushk replied to zohaib iftikhar's discussion ...* KAHAN HAI AB TUMHARI WO MOHABBAT ITNY SAALON KI ...*???
1 hour ago
Mushk replied to zohaib iftikhar's discussion ...*...*...* DAIKH MAIN TUJH SE KITNA PAYAR KRTA HON??? ...*...*...*
1 hour ago
zohaib iftikhar replied to zohaib iftikhar's discussion ....* TERI PALKON PE RUKNA HAI ...*
1 hour ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...*...* KAL SHAB KITAB-E-MAAZI KO JO MAIN NE KHOLA ...*...*??
1 hour ago
+ Ḱẚảḿḯ replied to Shanzay's discussion Ab hum faqt apni marzi ki baat kehty hain...
1 hour ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...* KAHAN HAI AB TUMHARI WO MOHABBAT ITNY SAALON KI ...*???
2 hours ago
zohaib iftikhar replied to zohaib iftikhar's discussion ...*...*...* DAIKH MAIN TUJH SE KITNA PAYAR KRTA HON??? ...*...*...*
2 hours ago
+!CS619!+ added a discussion to the group CS401 Computer Architecture and Assembly Language Programming
2 hours ago

Today Top Members 

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

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

.