C++ Input Output Statements (cout/cin) Practice 4

Let’s Do Some More Tasks in C++ To Practice input output statements (cin/cout) in C++.

You May also want to Check Part 1 , Part 2 and Part 3 of Input Output Statment Series Practice

Task 7:

Write a Program that takes number of students and their fee from user and display the total fee collected per month and per year.

Code:

#include<iostream>
using namespace std;
int main()
{
	//input variables
	int no_of_std;
	float fee;
	//taking input
	cout<<"Enter Number of Students in Class : ";
	cin>>no_of_std;
	cout<<"Enter Fee : ";
	cin>>fee;
	//output variables
	float f_per_month=no_of_std*fee;
	float f_per_year=no_of_std*fee*12;
	cout<<"\nTotal Fee Collected from these Students per Month is : "<<f_per_month;
	cout<<"\nTotal Fee Collected from these Students per Year is : "<<f_per_year;
	return 0;
}

Output:

Enter Number of Students in Class : 5
Enter Fee : 1300

Total Fee Collected from these Students per Month is : 6500
Total Fee Collected from these Students per Year is : 78000

Task 8:

Write a Program that Takes Temperature in Celsius from user and Displays the Temperature in Fahrenheit and Kalvin.
K= C+273
F= (9/5C+32)

Code:

#include<iostream>
using namespace std;
int main()
{
	//input variable
	float c;
	cout<<"Enter Temperature in Celsius : ";
	cin>>c;
	//output variables
	float k,f;
	k=c+273.0;
	f=(9.0/5.0)*c+32;
	cout<<"\nTemperature in Kalvin : "<<k<<endl;
	cout<<"\nTemperature in Fahrenheit : "<<f<<endl;
	return 0;
}

Output:

Related Post

1 Comment

Leave a Reply

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