C++

1. Program dodający dwie liczby

#include <iostream>
using namespace std;

int main()
{
int a,b,c;
cout << "podaj a" << endl;
cin >> a;
cout << "podaj b" << endl;
cin >> b;
c=a+b;
cout << "Wynik= "<<c << endl;
return 0;
}


2. Program dodający dwie liczby z instrukcją IF

#include <iostream>

using namespace std;

int main()
{
int a,b,c;
cout << "podaj a" << endl;
cin >> a;
cout << "podaj b" << endl;
cin >> b;
c=a+b;
cout << "Wynik= "<<c << endl;
if ( c>50)
{
c=c*2;
cout << "Superinio" << endl;
cout << "SUPER!!!!!! -----" << c <<endl;
}
else
{
c=c-20;
cout << "Slabelinio" << endl;
cout << "SLABO!!!! Wynik=" << c << endl;
}
return 0;
}

 


3. Petla for -przykład

using namespace std;

int main()
{
int i,ile;

cout << "ile razy krecisz glowa ";
cin >>ile;

for(i=0; i<ile ; i++)
{
cout << "Misie ----- " << i+1 << endl;
}
return 0;
}

 

Strona Główna Link do CodeBlocks-a