Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

-= Having Difficulties in C++ and Java? Be a Part of This Thread =-

Re: -= Having Difficulties in C++? Be a Part of This Thread =-

Ung first 2 input po ay integers then ung Pangatlo ay decimal po.

hmm..anu ba talaga?:slap:

2 input lang naman ang nilagay mo dun

Code:
cout<< "This method is use to solve the equation 7x^3 - 3x^2 +11x -2\n" << endl;
	cout<<"Please input a valid value for Xo: ";
	[COLOR="Red"]cin>> x;[/COLOR]
	cout<<"Please input a valid value for Es in %: ";
	[COLOR="red"]cin>> es;[/COLOR]
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

hmm..anu ba talaga?:slap:

2 input lang naman ang nilagay mo dun

Code:
cout<< "This method is use to solve the equation 7x^3 - 3x^2 +11x -2\n" << endl;
	cout<<"Please input a valid value for Xo: ";
	[COLOR="Red"]cin>> x;[/COLOR]
	cout<<"Please input a valid value for Es in %: ";
	[COLOR="red"]cin>> es;[/COLOR]

Pakitingin po dun sa attachments. Ayun po ung gusto ko po imean.
Ung first pic po, hindi nagloop po. Samantalang ung sa 2nd pic, which is pang-apat na try, nagloop po. Bale napansin ko po kapag 3,5,7,9 pataas na odd number, hindi po siya nagcocompute. Pero kapag 4,6,8,10 up even number, nagcocompute po siya.
 

Attachments

  • moss1.PNG
    moss1.PNG
    24.7 KB · Views: 4
  • moss2.PNG
    moss2.PNG
    29 KB · Views: 4
Last edited:
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

Pakitingin po dun sa attachments. Ayun po ung gusto ko po imean.

hmm..may error trapping pa pala :slap:

paki sabi po kasi lahat-lahat na details para hindi tayo nagsasayang ng oras :thumbsup:
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

hmm..may error trapping pa pala :slap:

paki sabi po kasi lahat-lahat na details para hindi tayo nagsasayang ng oras :thumbsup:

pasensya na po. Hindi ko po alam ung error trapping. Ngaun ngaun ko lang din po napansin ung ganun ang nangyayari. Thanks.. :slap:
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

pasensya na po. Hindi ko po alam ung error trapping. Ngaun ngaun ko lang din po napansin ung ganun ang nangyayari. Thanks.. :slap:

eto na

Code:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){

	float i, x, x2, e, es, mx1;
	
	cout<< "This method is use to solve the equation 7x^3 - 3x^2 +11x -2\n" << endl;
	cout<<"Please input a valid value for Xo: ";
	cin>> x;
	cout<<"Please input a valid value for Es in %: ";
	cin>> es;
	
	//Derived function used
	mx1 = (2*x);
	
	if(x<1){

		//Output of values 
		cout<<"\n"<<"\n"<<"i"<<"\t"<<"Xi"<<"\t"<<"\t"<<"E( %)\n";
		cout<<"0"<<"\t"<<x<<"\n"; 

		//Solution to equation 
		for(i=1,e=100;(e/100)>(es/100);i++){
			x2= ((x*x)-4) ;
			e=(abs((x2-x)/x2)*100);
			cout<<setprecision(4)<<i<<"\t"<<setprecision(4) << x <<"\t"<<"\t"<<e<<"\n";
			x=x2;
		}
	
		cout << endl << "\nTherefore, the root is "<< x <<endl;
	}
	else{
		while(x >= 1){
			cout<< endl << "The given Xo is not less than one!" << endl;

			cout<< endl << "Please input a valid value for Xo: ";
			cin>> x;
			cout<<"Please input a valid value for Es in %: ";
			cin>> es;
		
			//Derived function used
			mx1 = (2*x);
	
			if(x<1){

				//Output of values 
				cout<<"\n"<<"\n"<<"i"<<"\t"<<"Xi"<<"\t"<<"\t"<<"E( %)\n";
				cout<<"0"<<"\t"<<x<<"\n"; 

				//Solution to equation 
				for(i=1,e=100;(e/100)>(es/100);i++){
				x2= ((x*x)-4) ;
				e=(abs((x2-x)/x2)*100);
				cout<<setprecision(4)<<i<<"\t"<<setprecision(4) << x <<"\t"<<"\t"<<e<<"\n";
				x=x2;
			}
	
			cout << endl << "\nTherefore, the root is "<< x <<endl;
			break;
		}
			else{
				cout<< endl << "The given Xo is not less than one!" << endl;

				cout<< endl << "Please input a valid value for Xo: ";
				cin>> x;
				cout<<"Please input a valid value for Es in %: ";
				cin>> es;
				//Derived function used
				mx1 = (2*x);
			}
		}	
	}
	return 0;
}

wala akong ginalaw kung panu ang computation mo dun..kapag may mali man sa output..cgurado nasa formula mo yun :lol:
 
Last edited:
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

Ganun padin ung result sir. Salamat!!
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

naayos mo na ba sir?
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

A. Define an array named People Types that can store a maximum of 50 integer values that will be enter at the keyboad.enter a series of 1s,2s,3s, and 4s into the array where 1 represents an infant,2 represnts a child a 3 represents a teenager and a 4 reprsents and adult who was present at a local shcol function.any other integernvalue should not be accepted as valid input and data entry should stop when a negative has been enterd.
Your prorgrram should count the number of each 1,2,3,and 4 in the array and output a list of how many infants,children,teenagers and adults were at the school funtion


B.
Write a program that initally accepts a set of numerical grades from the keyboard into array.the maximum number of grades is 50 and data entry should be terminated when a negative number has beeb entered.have you program sort and print the grades in decending order in a function named sortDisp().

c.
write a program that will ask a user to input 10 integers that will be stored in an array.after inputing the values ,a menu will be displayed your menu will compose of 4 selections.
Menu
[1] view original
[2] Display increasing
[3] display decreasing
[4] exit
. when the user will input 1,the orignial inputed array will be displayed
.when the use will input 2, the aray will be displayed in increasing order.
.when the user will input 3, the array will be displayed in decreasing order
.when the user will input 4, the program will exit
There should ony be 1 array to be declared all thought your program and that should be decleard in the main function.write a separate function to arrange and display your array in increasing order and anotherr function to arrange and display your array in decreasing order.


help po mondy po deadline nmin yong project ko plz
 
c

A. Define an array named People Types that can store a maximum of 50 integer values that will be enter at the keyboad.enter a series of 1s,2s,3s, and 4s into the array where 1 represents an infant,2 represnts a child a 3 represents a teenager and a 4 reprsents and adult who was present at a local shcol function.any other integernvalue should not be accepted as valid input and data entry should stop when a negative has been enterd.
Your prorgrram should count the number of each 1,2,3,and 4 in the array and output a list of how many infants,children,teenagers and adults were at the school funtion


B.
Write a program that initally accepts a set of numerical grades from the keyboard into array.the maximum number of grades is 50 and data entry should be terminated when a negative number has beeb entered.have you program sort and print the grades in decending order in a function named sortDisp().

c.
write a program that will ask a user to input 10 integers that will be stored in an array.after inputing the values ,a menu will be displayed your menu will compose of 4 selections.
Menu
[1] view original
[2] Display increasing
[3] display decreasing
[4] exit
. when the user will input 1,the orignial inputed array will be displayed
.when the use will input 2, the aray will be displayed in increasing order.
.when the user will input 3, the array will be displayed in decreasing order
.when the user will input 4, the program will exit
There should ony be 1 array to be declared all thought your program and that should be decleard in the main function.write a separate function to arrange and display your array in increasing order and anotherr function to arrange and display your array in decreasing order.


monday deadline ng projcet ko
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

A. Define an array named People Types that can store a maximum of 50 integer values that will be enter at the keyboad.enter a series of 1s,2s,3s, and 4s into the array where 1 represents an infant,2 represnts a child a 3 represents a teenager and a 4 reprsents and adult who was present at a local shcol function.any other integernvalue should not be accepted as valid input and data entry should stop when a negative has been enterd.
Your prorgrram should count the number of each 1,2,3,and 4 in the array and output a list of how many infants,children,teenagers and adults were at the school funtion


B.
Write a program that initally accepts a set of numerical grades from the keyboard into array.the maximum number of grades is 50 and data entry should be terminated when a negative number has beeb entered.have you program sort and print the grades in decending order in a function named sortDisp().

c.
write a program that will ask a user to input 10 integers that will be stored in an array.after inputing the values ,a menu will be displayed your menu will compose of 4 selections.
Menu
[1] view original
[2] Display increasing
[3] display decreasing
[4] exit
. when the user will input 1,the orignial inputed array will be displayed
.when the use will input 2, the aray will be displayed in increasing order.
.when the user will input 3, the array will be displayed in decreasing order
.when the user will input 4, the program will exit
There should ony be 1 array to be declared all thought your program and that should be decleard in the main function.write a separate function to arrange and display your array in increasing order and anotherr function to arrange and display your array in decreasing order.


help po mondy po deadline nmin yong project ko plz

aral ka po ng mabuti....kung hindi mo alam..search ka lang sa internet..

kung medyo magpapaturo ka.hindi yung buong code..dapat gumawa ka rin ng sarili mong code..yung parang magtatanong ka lang kung nasaang parte ang mali

kung aasa ka lang sa tulong ng iba ng wala kang iniexert na effort..panu ka niyan magiging magaling na programmer?

By the way....goodluck po :salute:



Code:
// Problem A

#include <iostream>
using namespace std;

int infant, child, teenager, adult;

void school(){
	cout << endl << "There are " << infant << " infant/s. " << endl;
	cout << "There are " << child << " child/children. " << endl;
	cout << "There are " << teenager << " teenager/s. " << endl;
	cout << "There are " << adult << " adult/s. " << endl;

}

void condition(int a){
		if(a == 1)
			infant++;
		if(a == 2)
			child++;
		if(a == 3)
			teenager++;
		if(a == 4)
			adult++;
}

int main(){
	int People_Types[50], num, x;
	infant = 0, child = 0, teenager = 0, adult = 0;
	
	cout << "How many people's type do you want to input? : ";
	cin >> num;
	
	if( num > 50){
		cout << endl << "Sorry, the maximum number of grades allowed is 50 only" << endl;
		return 0;
	}
	if( num < 1){
		cout << endl << "Invalid number!" << endl;
		return 0;
	}
	else{
		cout << endl << "Please choose in the list" << endl << endl;
		cout << "[1] Infant" << endl;
		cout << "[2] Child " << endl;
		cout << "[3] Teenager" << endl;
		cout << "[4] Adult" << endl << endl;
	
		for(int i = 0; i < num; i++){
			cout << "Enter your classification: ";
			cin >> People_Types[i];
			x = People_Types[i];
			
			if( x <= 4 && x >= 1 )
				condition(x);
			if( x < 0 ){
				school();
				cout << endl << "You inputted a negative number. The program will now exit!" << endl;
				return 0;
			}
			else{
				while(x > 4 || x == 0){
					cout << endl << "The number you inputted is not found in the list. Enter another number!" << endl;
					if(x <= 4 && x >= 1){
						condition(x);
						break;
					}
					else{
						cout << endl << "Enter your classification: ";
						cin >> People_Types[i];
						x = People_Types[i];
						condition(x);
					}
				}
			}
		}
	}
	
	school();
	
	return 0;
}

Code:
// Problem B

#include <iostream>
using namespace std;

// To swap the numbers
void swap(int &a, int &b){
    int count = 0;
	int c;
	c = a;
	a = b;
	b = c;
}
// To sort the numbers
void doSort(int x[], int N,int &count){	
  count = 0;
  for (int i = 0; i < N-1; i++){
      for (int j = i+1; j < N; j++){
          if (x[i] > x[j]){
             swap(x[i], x[j]);
             count++;
          }
      }
  }
}

void sortDisp(int storage[], int answer){
	int count;
	doSort(storage,answer,count);
	cout << endl << "Grades in descending order: ";
	for(int i = (answer-1); i >= 0; i--){
		if(i != 0)
			cout << storage[i] << ", ";
		else
			cout << storage[i] << endl;
	}
}

int main(){
	int storage[50], answer, counter = 1, input = 0;
	
	cout << "How many grades do you want to input? : ";
	cin >> answer;
	if( num > 50){
		cout << endl << "Sorry, the maximum number of grades allowed is 50 only" << endl;
		return 0;
	}
	if( num < 1){
		cout << endl << "Invalid number!" << endl;
		return 0;
	}
	else{
		cout << endl;
		for(int i = 0; i < answer; i++){
			cout << "Enter grade # " << counter << " : ";
			counter++;
			cin >> storage[i];
			input++;
			if(storage[i] < 0){
				input--;
				sortDisp(storage, input);
				
				cout << endl << "You entered a negative grade. The program will now terminate!" << endl;
				return 0;
			}
			cout << endl;
		}
		sortDisp(storage, input);
	}
	return 0;
}

Code:
// Problem C

#include <iostream>
using namespace std;

// To swap the numbers
void swap(int &a, int &b){
    int count = 0;
	int c;
	c = a;
	a = b;
	b = c;
}
// To sort the numbers
void doSort(int x[], int N,int &count){	
  count = 0;
  for (int i = 0; i < N-1; i++){
      for (int j = i+1; j < N; j++){
          if (x[i] > x[j]){
             swap(x[i], x[j]);
             count++;
          }
      }
  }
}

// Original Order
void original(int storage[]){
	cout << "Original Order: ";
	for(int i = 0; i < 10; i++){
		if(i != 9)
			cout << storage[i] << ", ";
		else
			cout << storage[i] << endl;
	}
}

// Increasing Order
void increasing(int storage[], int count){
	cout << "Increasing Order: ";
	doSort(storage,10,count);
	for(int i = 0; i < 10; i++){
		if(i != 9)
			cout << storage[i] << ", ";
		else
			cout << storage[i] << endl;
	}
}

//Decreasing Order
void decreasing(int storage[], int count){
	cout << "Decreasing Order: ";
	doSort(storage,10,count);
	for(int i = 9; i >= 0; i--){
		if(i != 0)
			cout << storage[i] << ", ";
		else
			cout << storage[i] << endl;
	}
}

int main(){

	int storage[10], counter = 1, answer, count;
	
	for(int i = 0; i < 10; i++){
		cout << "Enter integer # " << counter << " : ";
		counter++;
		cin >> storage[i];
		cout << endl;
	}
	
	cout << endl << "Choose from the following options" << endl << endl;
	cout << "[1] view original" << endl;
	cout << "[2] Display increasing" << endl;
	cout << "[3] display decreasing" << endl;
	cout << "[4] exit" << endl;
	
	cout << endl << "Enter your answer: ";
	cin >> answer;
	cout << endl;
	
	if(answer == 1)
		original(storage);
	if(answer == 2)
		increasing(storage,count);
	if(answer == 3)
		decreasing(storage, count);
	if(answer == 4){
		cout << "The program will now exit" << endl;
		return 0;
	}
	else
		cout << "The inputted number is not in the choice!" << endl;

	return 0;
}
 
Last edited:
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

boss pa tulong naman kung panu ung code sa c++ para maging double vertical line ung output parang ganito

Enter a number 5

1 5
2 4
3 3
4 2
5 1



yan do while loop po yan
tnx.. :D
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

ts, beginner lang po,

ano po ba ang pagkakaiba ng Dev c++, code blocks , turbo c++, visual c++.

ano po ba magandang gamitin sa tulad kong beginner?
thanks in advance..
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

#include<iostream>
using namespace std;
int main()
{
int x = 1, y = 5;
while( x<=5 )
{
cout<< x <<" "<< y <<endl;
x++;
y--;
}

system("pause"); // wait user to press any key to continue...
return 0;
}

try mo din un isa lng un variable bka pede
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

#include<iostream>
using namespace std;
int main()
{
int x = 1, y = 5;
while( x<=5 )
{
cout<< x <<" "<< y <<endl;
x++;
y--;
}

system("pause"); // wait user to press any key to continue...
return 0;
}

try mo din un isa lng un variable bka pede

edit lang natin ng unti yan boss..para sumakto dun sa hinahanap ni coolfire77 :thumbsup:

Code:
// Credit to Marcmaa

#include<iostream>
using namespace std;

int main(){
	int x = 1, num;

	cout << "Enter a number: ";
	cin >> num;

	int temp = num;
	
	while( x <= temp ){
		cout<< x <<" "<< num <<endl;
		x++; num--;
	}

	system("pause"); 
	return 0;
}
 
Last edited:
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

:thanks: dito
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

Mga master papano po kaya icode to?

Enter your name(LastName, FirstName, MI): dela Cruz, Juan P.
Your name is Juan P. dela Cruz

ginamitan po namin ng string manipulation functions yan. ang di ko lang po magets ay kung papaano maalis yung ','
kumbaga ganito ang lumalabas
Your name is Juan P. dela Cruz,
ito po bali yung code ko.

Code:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>

main()

{
      char name[20], x[20], y[20];
      clrscr();
      cout<<"\nEnter your name (LastName, FirstName, MI):";
      gets(name);
      strcpy(x, strchr(name, ' '));
      strcpy(y, strrev(strchr(strrev(name), ',')));
      cout<<"\nYour name is" << x << y;
      getch();
      return 0;


}

thank you po sa makakatulong :)
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

Mga master papano po kaya icode to?

Enter your name(LastName, FirstName, MI): dela Cruz, Juan P.
Your name is Juan P. dela Cruz

ginamitan po namin ng string manipulation functions yan. ang di ko lang po magets ay kung papaano maalis yung ','
kumbaga ganito ang lumalabas
Your name is Juan P. dela Cruz,
ito po bali yung code ko.

Code:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>

main()

{
      char name[20], x[20], y[20];
      clrscr();
      cout<<"\nEnter your name (LastName, FirstName, MI):";
      gets(name);
      strcpy(x, strchr(name, ' '));
      strcpy(y, strrev(strchr(strrev(name), ',')));
      cout<<"\nYour name is" << x << y;
      getch();
      return 0;


}

thank you po sa makakatulong :)

eto yung akin :thumbsup:

Code:
#include <iostream>
#include <cstring>
using namespace std;

int main(){
      
	  string name, temp1 = "", temp2 = "", final = "";
	  int find;
	  
	  cout << "\nEnter your name (LastName, FirstName, MI):";
          getline(cin, name);
	  int len = name.length();
	  find = name.find(",",0);
	  for(int i=0; i<find; i++){
		 temp1 +=name[i];
	  }
	  for(int i=(find+1); i<len; i++){
		 temp2 +=name[i];
	  }
	  temp2 += " ";
	  final = temp2 + temp1;
	  
	  cout<<"\nYour name is " << final << endl;
     
          return 0;
}
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

mukhang tahimik tayo ngayon ah
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

boss baka meron ka jang code para sa convert numbers to words (billions)
 
Re: -= Having Difficulties in C++? Be a Part of This Thread =-

ts, beginner lang po,

ano po ba ang pagkakaiba ng Dev c++, code blocks , turbo c++, visual c++.

ano po ba magandang gamitin sa tulad kong beginner?
thanks in advance..

DevC++ <- wag mo na gamitin outdated na to
TurboC++ <- lalong wag mo na gamitin dahil mas matanda pa ata to sayo
VisualC++(2008 or 2010) or Code Blocks ang gamitin mo.

pare parehong IDE lang yan, meaning, hindi sila programming language, sila ay C++ IDE, hindi sila ung C++. Common mistake yan dito sa forum.
 
Back
Top Bottom