Jump to content

Recommended Posts

Posted

Γεια σας παιδιά  ελπίζω να σας αρέσει το share μου  και να σας φανεί χρήσιμο... Λοιπόν σκέφτηκα να κάνω έναν οδηγό για κάποιους που θέλουν να μάθουν τη γλώσσα προγραμματισμού C++ θα σας πω βασικές οδηγίες για να κάνετε ένα πρόγραμμα και να τρέξει σωστά. Ο compiler που χρησιμοποιώ είναι Borland c++ θα το βρείτε στο google.

Ας ξεκινήσουμε.

 

1) ΕΞΟΔΟΣ ΑΠΟΤΕΛΕΣΜΑΤΩΝ

 

Καταρχάς πρέπει να γνωρίζετε πως συντάσσεται ένα πρόγραμμα. Πάντα χρησιμοποιούμε μια βιβλιοθήκη για να ξεκινήσουμε. Η οποία ονομάζετε iostream για να την καλέσουμε γράφουμε #include <iostream> έπειτα γράφουμε το κυρίως πρόγραμμα με την εντολή main() έπειτα ανοίγουμε αγκύλη { και γράφουμε το πρόγραμμα μας και όταν τελειώσουμε το πρόγραμμά μας  δεν ξεχνάμε να την κλείσουμε }. Το τελευταίο που πρέπει να θυμόμαστε είναι να βάλουμε στο τέλος του προγράμματος τη λεγόμενη καθυστέρηση(delay) για να μπορεί το πρόγραμμα  όταν το τρέξουμε να εμφανιστεί στην οθόνη μας. χωρίς αυτή την εντολή το πρόγραμμα εξαφανίζετε αμέσως... Ετσι στο τέλος πάντα γράφουμε

int delay;

cin>>delay;

και μετά κλείνουμε την αγκύλη που ανοίξαμε στην αρχή με το main}

 

Η εντολή που χρησιμοποιούμε για να εμφανίσουμε αποτελέσματα γίνετε με την εντολή cout. Για παράδειγμα άμα θέλουμε να εμφανίσουμε στο πρόγραμμα μας τη λέξη γεια τότε γράφουμε :

#include <iostream>

main(){

 

cout<<"γεια";

int delay;

cin>>delay;

}

και πατάμε τον κεραυνό..

Προσοχη!!! Οταν θέλουμε να εμφανίσουμε κείμενο το γράφουμε σε " .... "

 

Άμα θέλουμε να εμφανίσουμε περισσότερα αποτελέσματα μπορούμε να τα βάλουμε μέσα σε ένα cout π.χ θέλουμε να εμφανίσουμε <γεια τι κάνεις;>

μπορούμε να το γράψουμε cout<<"γεια τι κάνεις"; μπορούμε και να το γράψουμε

cout<<"γεια"; 

cout<<"τι κάνεις; το αποτέλεσμα θα είναι το ίδιο. Άμα θέλουμε να εμφανίσουμε πάνω το "γεια" και από κάτω, τι "κάνεις" τότε χρησιμοποιύμε το <<endl; Το πρόγραμμά μας θα γραφτεί

cout<<"γεια "<<endl;

cout<<"τι κάνεις";

.

Αυτά είναι τα βασικά για να εμφανίζεις τις λέξεις και τις προτάσεις που θες.

 

 

2) ΕΜΦΆΝΙΣΉ ΠΡΆΞΕΩΝ

 

Για τις πράξεις είναι απλά τα πράγματα...  πάλι χρησιμοποιούμε την cout.  π.χ θέλουμε να μας υπολογίσει  την πράξη 1+1

#include <iostream>

main(){

cout<<1+1;

int delay;

cin>>delay}

Το αποτέλεσμα που θα δούμε είναι το 2 :P

Πρέπει να ξέρουμε τι σύμβολα χρησιμοποιούμε για τις πράξεις στη C++

Πρόσθεση: +

Αφαίρεση: -

Πολλαπλασιασμός: *

Διαίρεση: /

Ακέραιη διαίρεση, υπόλοιπο : %

Πρώτα γίνονται οι πράξεις στις παρενθέσεις,μετά οι πράξεις * / % και μετά  +  -

 

3) ΟΙ ΣΥΝΑΡΤΗΣΕΙΣ ΤΗΣ C++

 

Για να μπορέσει η Borland να επεξεργαστή συναρτήσεις πρέπει να καλέσουμε μια δεύτερη βιβλιοθήκη που ονομάζετε <math>

#include <math>

α) sqrt(x): Μας δίνει την τετραγωνική ρίζα ενός αριθμού π.χ cout<<sqrt(4); θα μας δώσει το 2

β)log(x): μας δίνει τον λογάριθμο π.χ cout<<log(1); θα μας δώσει το 0.

γ)exp(x): μας δίνει το e εις την x π.χ cout<<exp(1); θα μας δώσει το 2.71828

δ)sin(3.14/χ): μας δίνει το ημίτονο της γωνίας π/χ π.χ άμα θέλουμε το ημίτονο της γωνίας π/6. γράφουμε  cout<<sin(3,14/6);

ε)cos(3.14/x): μας δίνει το συνημίτονο της γωνίας π/χ. π.χ θέλουμε το συνημίτονο της γωνίας π/6 γράφουμε  cout<<cos(3.14/6);

στ)για την εφαπτομένη εγώ προσωπικά χρησιμοποιώ το ημ/συν δηλαδή για τον υπολογισμό της εφαπτομένης γωνιάς π/6 cout<<sin(3.14/6)/cos(3.14/6);

ζ)pow(x,y): μας δίνει το χ εις την y. π.χ cout<<pow(2,2); μας δίνει το 4

η)abs(x),fabs(x.0) : μας δίνει την απόλυτη τιμή . Η abs περιμένει ακέραιο αριθμό ενώ η fabs πραγματικό.

 

 

4) ΜΕΤΑΒΛΗΤΕΣ

Για να εκχωρήσουμε μεταβλητές χρησιμοποιούμε το int.. π.χ int x =1; int y=2;

cout<<x+y; θα μας δώσει 3.

Αν δεν δηλώσουμε το x,y αν κάναμε cout<<x+y; θα μας έβγαζε ερρορ γιατί είναι άγνωστα τα γράμματα μας..

 

 

5) ΔΗΛΩΣΗ ΤΙΜΩΝ ΑΠΟ ΤΟ ΠΛΗΚΤΡΟΛΌΓΙΟ

 

Για να μπορέσουμε να δώσουμε τιμές απο το πληκτρολόγιο μας στο πρόγραμμα χρησιμοποιούμε το cin>>x;

Έστω ότι θέλουμε να δηλώσουμε 2 αριθμούς απο το πληκτρολόγιο και ύστερα αυτους τους αριθμούς που δώσαμε να τους προσθέτει... Τοτε το πρόγραμμα ολοκληρωμένο γίνεται:

#include <iostream>

main(){

 

int x,y;

 

cout<<"Δωσε πρώτο νούμερο:";cin>>x;

cout<<"Δωσε δεύτερο νούμερο:";cin>>y;

 

cout<<"To αποτέλεσμα της πρόσθεσης είναι:"<<x+y<<endl;

cout<<" To αποτέλεσμα του πολλαπλασιασμού είναι: " <<x*y<<endl;

cout<<"Το αποτέλεσμα τις διαίρεσης είναι:"<<x/y<<endl;

 

int delay;

cin>>delay

}

 

 

 

Αυτά ήταν μερικά βασικά πράγματα από τι γλώσσα C++ περιμένω  τα σχόλια σας και τις απορίες σας.. Επίσης αν δώ ενδιαφέρον θα προσθέσω περισσότερα πράγματα στον οδηγό ..

 

Credits : douga

  • 2 weeks later...
Posted

Poli xrisimos odhgos gia tous niewbies,

gia pliri ma9isi enteliws noob dinw auton ton odhgo sta agglika :

http://www.mediafire.com/?r81x0etsg4u6u3t

Den thimame credits ton eixa sto pc.

Einai se html kai exw valei odhgies!

 

  • 2 weeks later...
  • 3 weeks later...
  • 10 months later...
Posted

Πολυ ωραιο το thread σου φιλε και βοηθαει πραγματικα.Και εγω πηγαινω τωρα σε μια σχολη που ασχολειται με τους υπολογιστες.Καναμε καποια μαθηματα πανω στη C++ αλλα μερικες εντολες οπως τη "delay" και το "endl" δεν τις ηξερα.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • I was looking for  server with a low rates,eventually i found l2 elixir.I Joined beta and after so many years since 2008 i found  a friend that we played together, memories came back. i cant wait for the grand oppening!. dont miss it!
    • Seems legit, for sure deserves a try!
    • SOCNET VERIFICATION SERVICE — is a universal solution for those who value security, convenience, and quality. We turn the verification process into a convenient, fast, and highly confidential experience. Thanks to our service, any of your accounts receive identity confirmation, an increased level of trust from platforms and users, as well as protection from bans, fraud, and risks.   Promotion: Pay for your first verification and get a 10% discount on the second one! 💎 We help with verification on Fragment, crypto exchanges ByBit, Gate, Bitget, OKX, Binance, PayPal, KuCoin, and social networks LinkedIn, Facebook, Instagram, Twitter (X) and many other platforms! 💎 Verification for any service: crypto exchanges, trading platforms, hosting providers, casinos and other websites. Why choose us:   Premium quality — we use the most advanced verification methods. High processing speed — accelerated verification on leading platforms, online services and social networks. Full confidentiality — your personal information is protected. Increased trust and status — a verified account boosts influence and improves conversion. Individual approach — we work with bloggers, brands, businesses, and private clients. Simplifying complexity — we handle issues when dealing with foreign services. Important! Services related to illegal activities are strictly prohibited! 💳 Service pricing   ✅ Verification of individuals — from $30 (the exact cost depends on the required location and service/app/website). Learn more 👨‍💼 The cost of business verification for companies or legal entities is discussed individually with the service administration. Learn more If you want us to register your account on the required service and verify it — you will need to additionally pay 10% of the transaction amount. Available payment methods: cryptocurrency, credit cards, PayPal, and other payment methods in our online store and Telegram bot.   ⭐ Our Online Store ⭐ SOCNET.STORE ⭐ Telegram Store ⭐ SOCNET.SHOP ⭐ Our SMS Service ⭐ SOCNET.APP ⭐ Our Telegram Bot for buying Telegram Stars ⭐ SOCNET.CC ⭐ Our SMM Panel ⭐ SOCNET.PRO   ✅ News Resources ➡ Telegram Channel ➡ WhatsApp Channel ➡ Discord Server     ⭐ We invite you to COOPERATE and EARN with us ⭐ Would you like to sell your product or service in our stores and earn money? Become our partner or offer mutually beneficial collaboration? You can contact us via the CONTACTS listed in this topic. ✅ Contacts & Support ➡ Telegram Support ➡ WhatsApp Support ➡ Discord Support: socnet_support ➡ Email Support: solomonbog@socnet.store   Terms of Use and Refund Policy If you have any questions or issues, our fast support service is ready to respond to your requests! A refund for a completed service that does not fully meet the requirements or the declared quality is possible only if the product description includes a warranty and a valid warranty period. In other cases, a full refund for the service will not be provided! By purchasing such a service, you automatically agree to our refund rules for non-provided services! Refunds for countries selected by mistake are not provided after verification. To complete verification, you must provide full access to your account. We currently accept cryptocurrency, credit cards, PayPal, and other payment methods in our online store and Telegram bot! We value every client and provide replacements in case of invalid accounts via our contact channels! Attention: Your order will be delivered to your personal Google Drive/Mega.nz via a link (check the link, click “View content”) within 24 hours after the order confirmation! If you purchased more than 1 item at once, your entire order will be delivered via the first link! The remaining links will be empty! You will automatically receive an email notification after delivery! If you pay on our website via PayPal, you must pay an additional 20% commission (minimum $1). To avoid this commission, you can pay me directly via PayPal — instructions are available on the website! Refunds for items purchased by mistake or due to “I chose the wrong product and did not use it” are not accepted! You are fully responsible for your actions before and after purchase.
    • SOCNET VERIFICATION SERVICE — is a universal solution for those who value security, convenience, and quality. We turn the verification process into a convenient, fast, and highly confidential experience. Thanks to our service, any of your accounts receive identity confirmation, an increased level of trust from platforms and users, as well as protection from bans, fraud, and risks.   Promotion: Pay for your first verification and get a 10% discount on the second one! 💎 We help with verification on Fragment, crypto exchanges ByBit, Gate, Bitget, OKX, Binance, PayPal, KuCoin, and social networks LinkedIn, Facebook, Instagram, Twitter (X) and many other platforms! 💎 Verification for any service: crypto exchanges, trading platforms, hosting providers, casinos and other websites. Why choose us:   Premium quality — we use the most advanced verification methods. High processing speed — accelerated verification on leading platforms, online services and social networks. Full confidentiality — your personal information is protected. Increased trust and status — a verified account boosts influence and improves conversion. Individual approach — we work with bloggers, brands, businesses, and private clients. Simplifying complexity — we handle issues when dealing with foreign services. Important! Services related to illegal activities are strictly prohibited! 💳 Service pricing   ✅ Verification of individuals — from $30 (the exact cost depends on the required location and service/app/website). Learn more 👨‍💼 The cost of business verification for companies or legal entities is discussed individually with the service administration. Learn more If you want us to register your account on the required service and verify it — you will need to additionally pay 10% of the transaction amount. Available payment methods: cryptocurrency, credit cards, PayPal, and other payment methods in our online store and Telegram bot.   ⭐ Our Online Store ⭐ SOCNET.STORE ⭐ Telegram Store ⭐ SOCNET.SHOP ⭐ Our SMS Service ⭐ SOCNET.APP ⭐ Our Telegram Bot for buying Telegram Stars ⭐ SOCNET.CC ⭐ Our SMM Panel ⭐ SOCNET.PRO   ✅ News Resources ➡ Telegram Channel ➡ WhatsApp Channel ➡ Discord Server     ⭐ We invite you to COOPERATE and EARN with us ⭐ Would you like to sell your product or service in our stores and earn money? Become our partner or offer mutually beneficial collaboration? You can contact us via the CONTACTS listed in this topic. ✅ Contacts & Support ➡ Telegram Support ➡ WhatsApp Support ➡ Discord Support: socnet_support ➡ Email Support: solomonbog@socnet.store   Terms of Use and Refund Policy If you have any questions or issues, our fast support service is ready to respond to your requests! A refund for a completed service that does not fully meet the requirements or the declared quality is possible only if the product description includes a warranty and a valid warranty period. In other cases, a full refund for the service will not be provided! By purchasing such a service, you automatically agree to our refund rules for non-provided services! Refunds for countries selected by mistake are not provided after verification. To complete verification, you must provide full access to your account. We currently accept cryptocurrency, credit cards, PayPal, and other payment methods in our online store and Telegram bot! We value every client and provide replacements in case of invalid accounts via our contact channels! Attention: Your order will be delivered to your personal Google Drive/Mega.nz via a link (check the link, click “View content”) within 24 hours after the order confirmation! If you purchased more than 1 item at once, your entire order will be delivered via the first link! The remaining links will be empty! You will automatically receive an email notification after delivery! If you pay on our website via PayPal, you must pay an additional 20% commission (minimum $1). To avoid this commission, you can pay me directly via PayPal — instructions are available on the website! Refunds for items purchased by mistake or due to “I chose the wrong product and did not use it” are not accepted! You are fully responsible for your actions before and after purchase.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock