100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Overig

COS1511- assignment 2 solutions with output 2023

Beoordeling
-
Verkocht
-
Pagina's
18
Geüpload op
11-05-2023
Geschreven in
2022/2023

This document contains the solutions to assignment 2 for COS With all the codes and comments in them, functions and outputs to every question

Instelling
Vak










Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
11 mei 2023
Aantal pagina's
18
Geschreven in
2022/2023
Type
Overig
Persoon
Onbekend

Onderwerpen

Voorbeeld van de inhoud

ASSIGNMENT 02 COS1511 2023
QUESTION 1a.
while(age>30||finalMark<65)

{

cout<<”Candidate not suitable.”<<endl;

cout<<”Enter age: “;

cin>>age;

cout<<”Enter final mark: “;

cin>>finalMark;

}



QUESTION 1b.
CODE OUTPUT
a. for(int i=1;i<=1;i++) *
cout<<”*”;
cout<<endl;
b. for(int i=2;i>=2;i++) Endless loop of *
cout<<”*”;
cout<<endl;
c. for(int i=1;i<=1;i--) Endless loop of *
cout<<”*”;
cout<<endl;
d. for(int i=12;i>=9;1--) ****
cout<<”*”;
cout<<endl;
e. for(int i=0;i<=5;i++) ******
cout<<”*”;
cout<<endl;
f. for(int i=1;i<=5;i++) Syntax error.
cout<<”*”; “i” is inaccessible after the for loop.
i=i+1;
cout<<endl;


QUESTION 1c.

,PROGRAM.
#include <iostream>

using namespace std;

int main()

{

int i=0;

while(i<=10)

{

if (i<5 && i!=2)

cout<<"X";

i++;

}

return 0;

}

Output.




QUESTION 1d.

, PROGRAM.
#include <iostream>

using namespace std;

const int LIMIT =10;

int main()

{



float counter;

//The declaration of variables can be on the same line separated by a comma.

int number, zeros, odds, evens;

//The counter variables are inirialised to assure that they don’t acquire an unknown initial value.

zeros=0;

odds=0;

evens=0;



cout<<"Please enter "<<LIMIT<<" integers, positive,negative or zeros."<<endl;

cout<<"The number you entered are "<<endl;

for(counter=1;counter<=LIMIT; counter++)

{

cin>>number;



switch(number%2) //The switch statement is working on a remainder and (%) is used.

{

case 0:

evens++;

if (number==0) //correcting the boolean operator for number is equal to zero…(==) not (=)

zeros++;

break;

Beschikbare oefenvragen

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
ThinkLab University of South Africa (Unisa)
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
171
Lid sinds
2 jaar
Aantal volgers
118
Documenten
107
Laatst verkocht
1 maand geleden
ThinkLab Tutorials

A group of tutors that upload notes, exam elaborations, exam packs, assignment solutions and free packs. Unlock the door to academic excellence with our top-notch document uploads! It's meticulously prepared with foolproof solutions that guarantee your success. Trust in our reliable resources and conquer any challenge that comes your way. Don't settle for anything less than perfection in your studies. Our reliable document boasts 100% correct solutions, meticulously reviewed for your success. Say goodbye to uncertainty and hello to unwavering confidence! Giving the best services as the modules we are uploading are considered. If you have any questions, you're welcome to message us directly.

Lees meer Lees minder
3,9

19 beoordelingen

5
7
4
5
3
6
2
1
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen