Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Programming

The document contains multiple C++ programming questions and their corresponding code solutions. Each question demonstrates different programming concepts such as loops, conditionals, input/output, and class definitions. The code snippets cover topics like grade calculation, day display based on input, patient details entry, and basic bank account operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming

The document contains multiple C++ programming questions and their corresponding code solutions. Each question demonstrates different programming concepts such as loops, conditionals, input/output, and class definitions. The code snippets cover topics like grade calculation, day display based on input, patient details entry, and basic bank account operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

QUESTION 1

#include<iostream>

using namespace std;

int main()

//input

for(int a=10; a>=1; a--)

//for loop declaration

cout<<a<<""<<endl;

//output

return 0;

QUESTION 2

#include<iostream>

using namespace std;

int main ()

int x,y;

float z;

x=10;
y=15;

z=12.6;

cout<<"x is an integer: "<<x<<endl;

cout<<"y is an integer: "<<y<<endl;

cout<<"z is a float: "<<z<<endl;

return 0;

QUESTION 3

#include<iostream>

using namespace std;

int main()

int grade;

int english,maths,shona;

cout<<"Enter english marks:"<<endl;

cin>>english;

cout<<"Enter maths marks:"<<endl;

cin>>maths;

cout<<"Enter shona marks:"<<endl;

cin>>shona;

grade=english+maths+shona;

if((grade>=90)&&(grade<=100))

{
cout<<"Grade A";

else if((grade>=70)&&(grade<90))

cout<<"Grade B";

else if((grade>=50)&&(grade<70))

cout<<"Grade C";

else if(grade<50)

cout<<"Grade F";

else

cout<<"Invalid";

return 0;

QUESTION 4a

#include<iostream>
using namespace std;

int main()

int num;

cout<<"Enter any number from 1-7 to display day: ";

cin>>num;

switch(num)

case 1: cout<<"Monday";

break;

case 2: cout<<"Tuesday";

break;

case 3: cout<<"Wednesday";

break;

case 4: cout<<"Thursday";

break;

case 5: cout<<"Friday";

break;

case 6: cout<<"Sartaday";

break;

case 7: cout<<"Sunday";

break;

default: cout<<"Invalid";

return 0;

}
QUESTION 4b

#include<iostream>

#include<string>

using namespace std;

int main()

string name,disease;

int ward;

char sex;

cout<<"Patient's Details: "<<endl;

cout<<"Enter Name: ";

cin>>name;

cout<<"Enter Ward: ";

cin>>ward;

cout<<"Enter sex: ";

cin>>sex;

cout<<"Enter disease treated: ";

cin>>disease;

cout<<"Patient's Details: "<<endl;

cout<<"Name: "<<name<<endl;

cout<<"Ward: "<<ward<<endl;

cout<<"Sex: "<<sex<<endl;
cout<<"Disease treated: "<<disease<<endl;

return 0;

QUESTION 5

#include<iostream>

using namespace std;

class bankAccount

public:

deposit (int amount);

withdrawal (int payment);

enquiry (int balance);

private:

int amount;

int payment;

int balance;

};

int main()

{
int deposit();

int withdrawal();

int enquiry();

int amount;

int payment;

int balance;

amount=3500;

balance=25500;

payment=2200;

cout<<"Enquiry balance : "<<endl;

cout<<balance;

amount+=balance;

balance-=payment;

cout<<"Total amount after disposal :"<<endl;

cout<<amount<<endl;

cout<<"The balance after withdrawal :"<<endl;

cout<<balance;

return 0;

You might also like