Η παρουσίαση φορτώνεται. Παρακαλείστε να περιμένετε

Η παρουσίαση φορτώνεται. Παρακαλείστε να περιμένετε

Ενισχυτική διδασκαλία

Παρόμοιες παρουσιάσεις


Παρουσίαση με θέμα: "Ενισχυτική διδασκαλία"— Μεταγράφημα παρουσίασης:

1 Ενισχυτική διδασκαλία
Ενότητα 6: «Εισαγωγή στον Προγραμματισμό με γλώσσα C και άλλες ασκήσεις ...» διδάσκων: χρήστος σκουρλάς,

2 Επίλυση ασκήσεων ... και άλλα παραδείγματα
Στην ενότητα αυτή θα λύσουμε και άλλες απλές ασκήσεις χρησιμοποιώντας γλώσσα προγραμματισμού c Στόχος μας να κατανοήσουμε περισσότερο κάποια θέματα προγραμματισμού στη γλώσσα αυτή. Χ. Σκουρλάς

3 #include <stdio.h>
int main (void) { // Define variables double a, b,c; printf("\n Hello!"); printf("\n Give me a = "); scanf("%lf", &a) ; printf("\n Give me b = "); scanf("%lf", &b) ; c = a+b; printf("\n The sum is c = %lf",c); printf("\n The sum with 7 total digits and 3 decimal digits is c = %7.31f", c); printf("\n The sum written scientifically is c = %e\n", c) ; return 0; }

4 Ανάλογα με το προϊόν και ειδικότερα για παλιότερες εκδόσεις μπορεί να χρειασθούν προσθήκες στο πρόγραμμά μας για να βλέπουμε τα αποτελέσματα πχ. #include <iomanip.h> #include <stdio.h> #include <iomanip.h> int main (void) { // Define variables double a, b,c; printf("\n Hello!"); printf("\n Give me a = "); scanf("%lf", &a) ; printf("\n Give me b = "); scanf("%lf", &b) ; c = a+b; printf("\n The sum is c = %lf",c); printf("\n The sum with 7 total digits and 3 decimal digits is c = %7.31f", c); printf("\n The sum written scientifically is c = %e\n", c) ; system("pause"); return 0; }

5 #include <stdio.h>
int main(void) // calculate 2*pi*r { // Define variables float r=2.5; float t; float pi=3.14; t=2*pi*r; printf("aktina r= %5.2f m \n", r); printf("mhkos perifereias kuklou aktinas t= %5.2f m \n", t); printf("mhkos perifereias kuklou aktinas t= %7.3f m \n", t); return 0; }

6 #include <stdio.h>
int main(void) // read 3 numbers, calculate sum and average { // Define variables float sum, average, x1, x2, x3; printf("give 3 numbers \n"); scanf("%f %f %f", &x1, &x2, &x3); printf("print the 3 numbers\n"); printf("%5.3f %5.3f %5.3f\n", x1, x2, x3); sum=x1+x2+x3; average=sum/3.0; printf("sum=: %5.3f \n", sum); printf("average=: %5.3f \n", average); return 0; }

7 #include <stdio.h>
#include <math.h> int main(void) // solve equation { // Define variables double a, b, c, d, xl, x2; printf("\nGive value a (non-zero)"); scanf("%lf", &a) ; printf("\nGive value b ") ; scanf("%lf", &b) ; printf("\n Give value of c ") ; scanf("%lf", &c) ; d=b*b-4*a*c; if (d==0.0) xl = -0.5*b/a; printf("\nThe double root is x= %f ", xl); printf("\n "); } else if (d<0) { printf("\n No real roots "); printf("\n "); } xl=0.5*(-b+sqrt(d))/a; x2=0.5*(-b-sqrt(d))/a; printf("\nThe two roots are xl= %f and x2=%f", xl, x2); return 0;

8 cout #include <iostream> cin
#include <iostream> int main() { std::cout<<"Hello World!\n"; return 0; } #include <iostream> cin cout

9 #include <iostream>
#include <iomanip> int main() { std::cout<<std::setw(60)<<"Programmer: Student "<<std::endl; std::cout<<std::setw(60)<<"if... else if...else "<<std::endl; int i; std::cout<<"give me a number "; std::cin>>i; if(i==0) std::cout<<"number is 0 "<<std::endl; else if (i>0) std::cout<<"positive number"<<std::endl; if (i>10) std::cout<<i<<" > 10"<<std::endl; else if (i==10) std::cout<<"einai iso me to 10 "<<std::endl; else std::cout<<i<<" < 10"; } std::cout<<"negative number"<<std::endl; return 0;

10 #include <stdio.h>
int main (void) { printf("typwse tis vasikes diastaseis (se bytes) twn typwn ths C :\n\n"); printf(" char: %3d byte(s)\n",sizeof(char)); printf(" short: %3d byte(s)\n",sizeof(short)); printf(" int: %3d byte(s)\n",sizeof(int)); printf(" unsigned: %3d byte(s)\n",sizeof(unsigned)); printf(" long: %3d byte(s)\n",sizeof(long)); printf(" float: %3d byte(s)\n",sizeof(float)); printf(" double: %3d byte(s)\n",sizeof(double)); printf(" long double: %3d byte(s)\n",sizeof(long double)); return 0; }

11 #include <stdio.h>
int main(void) { printf(" Metatropi Arithmwn apo to ena sistima sto allo \n\n"); printf("D = Decimal - H = Hexadecimal - O = Octadecimal\n"); printf("D - H - O\n"); printf("%d %x %o\n",19,19,19); printf("H - D - O\n"); printf("%x %d %o\n",0x15,0x15,0x15); printf("O - H - D\n"); printf("%o %x %d\n",012,012,012); return 0; }

12 Ερωτήσεις


Κατέβασμα ppt "Ενισχυτική διδασκαλία"

Παρόμοιες παρουσιάσεις


Διαφημίσεις Google