Pia tunatoa huduma zifuatazo.

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

Saturday, September 15, 2018

Question 2: Write C++ program to calculate the sum and average marks scored by students

Question: Write C++ program to calculate the sum and average marks scored by Mazoezi secondary school form four student in the following subjects;physics,chemistry,biology,mathematic and English if the marks are entered from the keyboard:
Solution


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



Question 1: Write a C++ program that display the following output


Question: Write a C++ program that display the following output
WELCOM TO SONGEA TEACHERS COLLEGE
                        ****************************
CHUO BORA CHA UWALIMU
               ENJOY
                        O
                        U
                        R
SERVICES

####################################################################################ADD YOU REGISTRATION NUMBER HERE####################
Solution

#include<iostream>
using namespace std;
int main(){
cout<<"\n WELCOME TO SONGEA TWACHER'S COLLEGE\n";
cout<<"\t****************************\n";
cout<<"\tCHUO BORA CHA UWALIMU\n";
cout<<"\t\tENJOY \n\t\tO\n\t\tU\n\t\tR\n \t\tSERVICES\n";
cout<<"\n\n\tSTC/2018/XXXX\n";
return 0;
}

OUTPUT

Saturday, July 21, 2018

Question involving WHILE loop in C++, well solved


Question: Write a simple program that will prompt a user to enter an integer between 1 and 20. Then the program will print on screen the numbers starting from 1 and ending at the number that the user has entered. Example: If a user enters 6 then the program should print "1 2 3 4 5 6". If a user enters a value outside the specified range, it should give a message: "Incorrect input. Enter number between 1 and 20". (Note: Use WHILE loop);

Solution:


Code description:
int a; int a is a variable declaration for an ending point.

cin>>a; this line inputs user data for an ending point e.g. 6 to output 1 2 3 4 5 6

(a<1 || a>20) Is a conditional statement that checks if a user has entered a value outside the specified range, if this statement is true then the line cout<<"Incorrect input. Enter number between 1 and 20\n"; will be executed otherwise the else block is to be executed.

while(i<=a){
           cout<<i<<" ";
           i++;
}
The while loop loops from 1 to an ending point input by a user, it will display 1 at the start as the initial point of i has been set int i = 1; above and will increment(i++) by one for every iteration, and will stop the iteration when it reaches the number entered by a user...