Pia tunatoa huduma zifuatazo.

Tunatengeneza blogu, tovuti(website), youtube chaneli n.k.. Mawasiliano:
simu:+255763670000, Barua pepe: khalfanm021@gmail.com

Sunday, September 16, 2018

Question Aim: Pascal triangle using array

Question: Write a C++ program using array that will print or display pascal triangle

Solution


NOTE: For a newbie in C++ it's difficult to understand the solution above as it has POINTERS, but don't worry about that, YOU JUST REVISIT THIS BLOG LATER ON THE DISCRIPTIONS OF THE CODES ABOVE WILL BE GIVEN


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL



Question aim: Displaying pascal triangle without using array

Question: Write a C++ program that prints or displays pascal triangle on screen

Solution



PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL



Question aim: Calculating average using a while loop in entering values

Question:  Write a C++ program that asks a teacher to enter marks of five  subjects of his/her student and then calculate the average of the marks entered.
HINT: Use a while loop to iterate the five marks entered, when the fifth mark has been entered, the loop should exit, calculate the average and display the result. Sample output should be;

     Enter marks: 10
     Enter marks: 20
     Enter marks: 30
     Enter marks: 40
     Enter marks: 50
    The average is: 30.00

Solution


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL



Question aim: Determination of negative or positive number and its weight in another number

Question: Write a c++ program to ask a user to enter a number, if a number is negative it should display "Negative number entered!" else if it is positive, it should determine if that number is greater than 10 or not.

Solution



PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

Question Aim: testing whether the lengths supplied form a triangle.

Question: The triangle inequality theorem states that the sum of the lengths of any two sides of a triangle must be greater than or equal to the length of the third side. Write a program that asks a user tp enter lengths of the three sides of a triangle. The program then tests whether the lengths supplied form a triangle.

Solution


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

Question Aim: Determination of odd or even number


Question: Write a C++ program to check whether a number entered by user is odd or even.

Solution


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

Question Aim: To calculate the volume of a sphere


Question: Write a block of code that prompts user to enter the radius, then compute and output the volume of a sphere. (Recall that volume V of a sphere of radius r is given by V = (4/3)PIr3 and assume PI = 3.14

Solution

if(r <= 0) This condition ensures that the radius cannot be zero or negative


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

Saturday, September 15, 2018

Question 5: Write c++ program check if the employee is eligible for bonus or not


Question 5: The current year and the year in which the Songea Teachers College employee joined the institution entered through the keyboard. if the number of years for which the employee has saved the college is greater than 10years,then the bonus of Tsh.250,000/= is given to the employee. if the years of the service is not greater than 10year,then the program should not do anything
Write c++ program check if the employee is eligible for bonus or not

Solution

#include<iostream>
using namespace std;
int main(){
int a,b,d;
cout<<"Enter the current year\n";
cin>>a; /*a implies the current year*/
cout<<"Enter the year an employee joined the institution\n";
cin>>b; /*b implies the year of joining the institution*/
d = a - b; /*Gets the difference of two years*/
if(> a){
cout<<"The current year cannot be less than the year in which an employee joined the institution\n";
}else{
if(>= 10){
cout<<"\nAn employee is eligible for the bonus of Tsh.250,000/=\n";  
}else{
cout<<"\nAn employee is not eligible for the bonus of Tsh.250,000/=\n";  
}
}
return 0;
}


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

Question 4: Write c++ program compute amount (expenses) that will be paid by customer


Question 4: While purchasing C++ programming books at the STC Bookstore discount of 12.5% is offered if the number of books purchased is more than 1000.if the number of book and price per book are input through keyboard
Write c++ program compute amount (expenses) that will be paid by customer
HINT: provide your answer in two decimal places

Solution

#include<iostream>
using namespace std;
int main(){
int n,price,the_discount,n_price;
const float DISCOUNT = 0.125; /*This is equal to 12.5%*/
cout<<"Enter the number of books to be sold\n";
cin>>n;
cout<<"Enter the price per book to be sold\n";
cin>>price;
if(n >= 1000){
the_discount = price * DISCOUNT;
n_price = price - the_discount;
cout<<"Total books: "<<n<<endl;
cout<<"Original price per book: "<<price<<endl;
cout<<"Price after discount: "<<n_price<<"\n\n";
cout<<"Total costs: "<<(n_price*n)<<".00"<<endl;
}else{
cout<<"Total books: "<<n<<endl;
cout<<"Original price per book: "<<price<<endl;
cout<<"Price after discount: "<<"No discount"<<"\n\n";
cout<<"Total costs: "<<(price*n)<<".00"<<endl;
}
return 0;
}


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

Question 3:Write C++ Program to Find Largest Number among Three Numbers

Question 3:Write C++ Program to Find Largest Number among Three Numbers
Solution

#include<iostream>
using namespace std;
int main(){
float a,b,c;
cout<<"\nC++ PROGRAM TO CHECK THE GREATEST NUMBER\n\n";
cout<<"Enter the first number\n";
cin>>a;
cout<<"Enter the second number\n";
cin>>b;
cout<<"Enter the third number\n";
cin>>c;
if(a>&& a>c){
cout<<"The first number which is " <<a<< " is the largest than "<<b<<" and "<<c<<endl;
}else if(b>&& b>c){
cout<<"The second number which is " <<b<< " is the largest than "<<a<<" and "<<c<<endl;
}else{
cout<<"The last number which is " <<c<< " is the largest than "<<b<<" and "<<a<<endl;
}
return 0;
}



PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL