c1

petak, 13. travnja 2012.

10. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int option=1;
    while(option!=0){
    cout<<"How many numbers you want to enter: ";
    int howMany;
    cin>>howMany;
    int array[howMany];
    cout<<"Write those numbers: "<<endl;
    for(int i=0;i<howMany;i++){
            cin>>array[i];
         
            }
            cout<<endl<<endl;;
    cout<<"Choose the option that you want:  "<<endl;
    cout<<"1)  Write from first to last..... "<<endl;
    cout<<"2)  write from last to first.....  "<<endl;  
    cout<<"0)  Exit... "<<endl;
    cin>>option;  
    cout<<endl;
    switch(option){
      case 1:{
       for(int i=0;i<howMany;i++){
               cout<<array[i]<<", ";
               }
             
       break;
                        }
      case 2:{
       for(int i=howMany-1;i>=0;i--){
               cout<<array[i]<<", ";
               }
       break;
                        }
         
}
    cout<<endl;
                }        
    cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}



9. Simple C++ Program - Tutorial


/*
In this program we use calculating operations like adding, multiplying, dividing and subtracting numbers...
*/


#include <iostream>
using namespace std;
int main()
{
    int option=1;
    while(option!=0){
    double number1;
    double number2;
    int option2;
    cout<<"Choose the option that you want:  "<<endl;
    cout<<"1)  Add two numbers...  "<<endl;
    cout<<"2)  Subtract two numbers...  "<<endl;
    cout<<"3)  Multiply two numbers...  "<<endl;
    cout<<"4)  Divide two numbers...  "<<endl;
    cout<<"0)  Exit... "<<endl;
    cin>>option;
    if(option!=0){
    cout<<endl<<"Enter two numbers:   "<<endl;
    cin>>number1;
    cin>>number2;
                 }
    cout<<endl;  
    switch(option){
      case 1:{
       cout<<number1<<" + "<<number2<<" = "<<number1+number2<<endl;
       break;
                        }
      case 2:{
       cout<<number1<<" - "<<number2<<" = "<<number1-number2<<endl;
       break;
                        }
      case 3:{
       cout<<number1<<" x "<<number2<<" = "<<number1*number2<<endl;
       break;
                        }
      case 4:{
       cout<<number1<<" : "<<number2<<" = "<<number1/number2<<endl;
       break;
                        }      
}
    cout<<endl;
                }          
    cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

code

after we run and use program

8. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int option=1;
    while(option!=0){
    int number1;
    int number2;
    cout<<"Please enter 2 numbers: "<<endl;
    cin>>number1;
    cin>>number2;
    cout<<"All odd numbers between these two numbers are: ";
    for(int i=number1+1;i<number2;i++){
            if(i%2!=0){
                 cout<<i<<", ";  
                       }}        
    cout<<endl<<endl;
    cout<<"To exit type 0 , if you want to try again type any other number:";
    cin>>option;
    cout<<endl<<endl;
                }          
    cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}


četvrtak, 12. travnja 2012.

7. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int option=1;
    while(option!=0){
    int number1;
    int number2;
    cout<<"Please enter 2 numbers: "<<endl;
    cin>>number1;
    cin>>number2;
    cout<<"All even numbers between these two numbers are: ";
    for(int i=number1+1;i<number2;i++){
            if(i%2==0){
                 cout<<i<<", ";    
                       }}          
    cout<<endl<<endl;
    cout<<"To exit type 0 , if you want to try again type any other number:";
    cin>>option;
    cout<<endl<<endl;
                }          
    cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}


srijeda, 11. travnja 2012.

6. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int option=1;
 
    while(option!=0){
    int number1;
    int number2;
    cout<<"Please enter 2 number which you want to add: "<<endl;
    cin>>number1;
    cin>>number2;
    cout<<"When we add these 2 numbers we get: ";
    cout<<number1+number2<<endl<<endl;
    cout<<"To exit type 0 , if you want to try again type any other number:";
    cin>>option;
    cout<<endl<<endl;  
                }            
            cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

utorak, 10. travnja 2012.

5. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int number;
    cout<<"Please enter number: ";
    cin>>number;
    if(number>10){
                  cout<<"The number that you entered is bigger than 10"<<endl;
                  }
    else{
         cout<<"The number that you entered is not bigger than 10"<<endl;
         }
            cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

4. Simple C++ Programs - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int number1;
    int number2;
    cout<<"Please enter first number: ";
    cin>>number1;
    cout<<"Please enter last number: ";
    cin>>number2;
    cout<<"Now we will write all numbers between First and the Last number: "<<endl;
    cout<<"Number are:  ";
    for(int i=number1+1;i<number2;i++){
            cout<<i<<", ";
            }
            cout<<endl<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

3. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int number;
    cout<<"Please enter your number: ";
    cin>>number;
    cout<<endl;
    cout<<"Write this on the screen:   "<<number<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

2. Simple C++ Program - Tutorial


#include <iostream>
using namespace std;
int main()
{
    int number;
    number=6;
    cout<<"Write this on the screen:   "<<number<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}


1. Simple C++ Program - Tutorial


/* this is first program, and after we run program, on screen will be only "Write this on the screen",as you can se on the picture....
*/
#include <iostream>
using namespace std;
int main()
{
    cout<<"Write this on the screen"<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}