Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert pseudo in C++
05-07-2013, 10:12 AM, (This post was last modified: 05-07-2013, 10:23 PM by Xantium.)
Post: #1
Convert pseudo in C++
Q.1
Code:
Convert this pseudocode algorithm to C++ progamming


//Initialize passes to zero
//Initialize failure to zero

//Input the exam result

     //If the student passed
      //Add one to passes
      //else
    //Add one to failures

//Print the number of passes
//Print the number of failures

Quote:#include <iostream>
#include <string>

using namespace std ;

int main()
{
int a = 0 ;
int b = 0 ;

aku hanya dpt berfikir smpai situ je

Q2.
Code:
Write a program to multiply two numbers. The program will display the output of the multiplication.

-    Declare the variable numbers to X and Y.
-    These variable X and Y carry the value of integer.
-    The two numbers will be obtained from user input.
-    Assign the answer to variable result that carry value integer.
Answer Q.2
Spoiler:


#include <iostream>
using namespace std;

int main()
{
int multiply ;
int x ;
int y ;

cout<<"Insert a Number = ";
cin>>x;
cout<<"Insert a Second Number = ";
cin>>y;

multiply = x*y ;

cout<<"The Calculation of Multiply is = "<<multiply<<"\n" ;

system("PAUSE");
return 0;
}

Can u See Me
Troll 2
Reply
05-07-2013, 10:52 AM, (This post was last modified: 05-07-2013, 11:09 AM by shahril.)
Post: #2
RE: Convert pseudo in C++
Code:
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main()
{
    //Initialize passes to zero
    //Initialize failure to zero
    int passes=0;
    int failure=0;

    // end Initialize

    //Input the exam result

     //If the student passed
      //Add one to passes
      //else
    //Add one to failures

    string pelajar[5] = { "Faez", "Akmal", "Muhammad", "Najib", "Razak" };
    int pelajar_length = (sizeof(pelajar)/sizeof(pelajar[0]))-1;

    char input[6];

    int kira=0;
    int num;
    while(pelajar_length >= 0){
        num=0;
        cout << pelajar[kira] << " score : ";
        fgets(input, 6, stdin);
        num=atoi(input);
        if(num > 100 || num <= 0){
            cout << "\nPlease enter correct score!\n";
            continue;
        }else{
            if(num > 40 && num <= 100){
                passes++;
            }else{
                failure++;
            }
        }
        kira++;
        pelajar_length--;
    }

    // end input and checking

    //Print the number of passes
    //Print the number of failures

    cout << "\n\nTotal Student = " << kira << endl;
    cout << "Passes = " << passes << endl;
    cout << "Phailed = " << failure << endl;

    // end print

    return 0;
}

ingtkan mata pelajaran, student rupanya, ceit ;d
Reply
05-07-2013, 11:00 AM,
Post: #3
RE: Convert pseudo in C++
Code:
pass = 0
fail = 0
bil_pelajar = 0

Input jumlah_pelajar

ULANG:
     input exam_result
     if exam_result > 40
         pass++
     else
         fail++
     end if

     bil_pelajar++
     if bil_pelajar <= jumlah_pelajar GOTO ULANG

output pass/fail

cuba convert yang ni...

input/output/ = cin/cout/atoi
loop = for/do...while/while
Reply
05-07-2013, 09:59 PM, (This post was last modified: 05-07-2013, 10:22 PM by Xantium.)
Post: #4
RE: Convert pseudo in C++
da setel da , jap nnti aku post , aku on kt pc ni

Code:
#include <iostream>
#include <string>

using namespace std ;

int main()
{
    int a = 0 ;
    int b = 0 ;
    double exam_result ;

    cout<< "Enter Your Exam Result : " ;
    cin>>exam_result ;
    
    if ( exam_result >= 40 )
        a = a+1 ;
    else
        b = b+1 ;

    cout<<"Number Of Passes is " <<a ;
    cout<<"\n Number of Failure is " <<b <<endl ;

    system ("pause") ;
    return 0 ;

}

#UPDATE POST Big Grin see first post for the 2nd question , n tgk answer dia , betul tk GayFace
Can u See Me
Troll 2
Reply
05-07-2013, 10:36 PM,
Post: #5
RE: Convert pseudo in C++
a'ah dah betul dah tu
sight nay cer
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  convert math formula kepada c++/c kangkunggoreng 14 1,814 14-11-2011, 08:28 PM
Last Post: johnburn

Forum Jump: