*   >> läser Utbildning artiklar >> education >> college and university

Modul 6: Introduktion till C och C ++

MODUL 6 Omdömen

---------------------------- --------------------- #include //för systemet () #include ... {C ++ koder ...} --------- ---------------------------------------- bör ändras till: ----- -------------------------------------------- #include //användning C ++ wrapper att ringa C-funktioner från C ++ program ... #include using namespace std; ... {C ++ koder ...} ---------------------------------------- --------- I VC ++ /VC ++ .Net den iostream.h (rubrik med .h) är inte giltigt längre. Det bör vara C ++ sidhuvud, så att den överensstämmer med standarden.

I äldre Borland C ++ kompilator detta fortfarande fungerar, men inte korrekt längre ... och för standard C /C ++ att överföra ska vara några problem eller bättre du läser Module23 på https://www.tenouk.com/Module23.html att få helheten ... För C-koder, de fortfarande C koder: o) ================================= ======================================== ========== ================================================== ============= #include int main () {float hastighet = 5,0; int timmar = 25; float lön = (float) timmar * hastighet; printf ("\\ Npay = $% 2f \\ n.

", lön); återvända 0; } ------------------------------------------------- -------------------------------------------------- //chnage headerfilerna följaktligen för andra C ++ exempel ... //# include //# include //using namespace std; #include #include int main () {int job_code; dubbel housing_allowance, entertainment_allowance, car_allowance; cout cin >> job_code; //om 1 väljs om (job_code == 1) {car_allowance = 200,00; housing_allowance = 800,00; entertainment_allowance = 250,00; cout cout //annat än en else {car_allowance = 100,00; housing_allowance = 400,00; entertainment_allowance = 150,00; cout cout systemet ("paus"); återvända 0; } ------------------------------------------------- -------------------------------------------- #include #include int main () {char job_title; int years_served, no_of_pub; cout cout cin >> job_title; cout cin >> years_served; cout cin >> no_of_pub; if (job_title == "T") {if (years_served> 15) if (no_of_pub> 10) cout annat cout annat cout} else if (job_title == "L") {if (years_served> 10) if (no_of_pub> 5 ) cout annat cout annat cout} else if (job_title == "A") {if (years_served> 5) om (no_of_pub> 5) cout annat cout annat cout} cout system ("paus"); återvända 0; } ------------------------------------------------- ------------------------------------ #include #include int main () {int varumärke, cout cin >> märke; if (märke cout else if (markera cout else if (markera cout else if (markera cout else if (märke cout annat cout cout systemet ("paus"), åter 0;} ------------ -------------------------------------------------- ------------------------ //Program exempel på if-else uttalande.

Detta program //är att testa om en banktransaktion är en insättning, //uttag, överföring eller en ogiltig transaktion, //och att vidta nödvändiga åtgärder #include #include int main () {float belopp,. röding transaction_code; cout cout cin >> transaction_code if (transaction_code == 'D') { cout cout cin >> belopp, cout cout} else if (transaction_code == "W") {cout cout cin >> belopp, cout cout} else if (transaction_code == "T") {cout cout cin >> belopp; cout cout} else {cout cout cout} cout system ("paus"); return 0;} ------------------------------ -------------------------------------------------- - //Exempel på program, Menyval #include #include int main () {char val; cout cout cout cout cout cout cout cin >>

Page   <<       [1] [2] [3] [4] [5] [6] [7] [8] >>
Copyright © 2008 - 2016 läser Utbildning artiklar,https://utbildning.nmjjxx.com All rights reserved.