100% satisfaction guarantee Immediately available after payment Read online or as PDF No strings attached 4,6 TrustPilot
logo-home
Other

This is a memo regarding assignment 2 solutions..

Rating
-
Sold
-
Pages
12
Uploaded on
15-08-2023
Written in
2023/2024

Assignment 2 2o23 - Introduction to programming c++ solutions a+

Content preview

Question 1a
#include <iostream>

using namespace std;

int main()
{
int age=0;
int finalMark=0;
cout<<"Enter age ";
cin >> age;
cout << "Enter final mark for exam ";
cin >> finalMark;

if((age<30) && (finalMark > 65)){
cout << "Your application is successful"<<endl;
}else
{
while(!((age<30) && (finalMark > 65)))
{
cout << "Your application is unsuccessful" <<endl;
cout<<"Enter age ";
cin >> age;
cout << "Enter final mark for exam ";
cin >> finalMark;

if((age<30) && (finalMark > 65)){
cout << "Your application is successful"<<endl;
break;
}
}
return 0;
}}

Output:




Question 1b

, Code Output
A for (int i = 1; i <= 1; i++){ *
cout << ‘*’;
cout << endl;
}
B for (int i = 2; i >= 2; i++){ *
cout << ‘*’; cout << endl;} *
*
* // infinite loop
*
*
C for (int i = 1; i <= 1; i--){ *
cout << ‘*’; *
cout << endl;} *
* // infinite loop
*
*
D for (int = 12; i >= 9; i--) cout << *
‘*’; cout << endl; *
*
*
E for (int i = 0; i <= 5; i++) cout *
<< ‘*’; cout << endl; *
*
*
*
*
F for (int i = 1; i <= 5; i++) cout *
<< ‘*’; i = i + 1; cout << endl; *
*

Question 1c

#include <iostream>

using namespace std;

int main()
{
int i = 0;
while( i <= 10){

if (i < 5 && i != 2){
cout << 'X';}
i++;
if(i == 10){break;}
}
}
Question 1d

#include <iostream>


using namespace std;

const int LIMIT = 10;
int main ()
{
float counter = 0;
int number = 0;

Document information

Uploaded on
August 15, 2023
Number of pages
12
Written in
2023/2024
Type
OTHER
Person
Unknown

Subjects

R86,00
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Read online or as PDF
No strings attached

Get to know the seller
Seller avatar
modschool

Get to know the seller

Seller avatar
modschool udemy
View profile
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
2
Last sold
-

0,0

0 reviews

5
0
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions