i need some help about my assignment can anyone help me it is urgent .plss....

C-style cast or function-style cast
what is it???
give can you give some idea///??
plsss..
Last edited on
I assume you mean this:
C-Style:
1
2
   int A = 5;
   char H = (char)A; //C-Style type cast 


"Function"/C++ style:
1
2
   int A = 5;
   char H = char(A); //C++ Style type cast 


There are also other type casts (reinterpret, dynamic, static, const):
1
2
   int A = 5;
   char H = reinterpret_cast<char>(A);


you can use all of them, and all of them works.
thank you but i dont konow where i suppose to place...it

here my code:
#include <iostream.h>

int main()
{
int age=0;
char citizen=(char)y || n;
int citizen = 5;
char citizen = reinterpret_cast<char>(y);


cout<<"Enter your age";
cin>> age&&citizen;
if (age>=18 || age<18)
{
cout<<"Are you filipino citizen?(y/n):"<<endl;
cin>> citizen;
{
if (citizen=="y")
{
cout<<"You are eligible to vote"<<endl;
}
else
{
cout<<"You are not eligible to vote"<<endl;
if else
{

cout<<"Are you filipino citizen?(y/n):"<<endl;
cin>> citizen;
{

if (citizen==y)
{
cout<<"You are eligible to vote"<<endl;
}
else
{
cout<<"You are not eligible to vote"<<endl;

}
}
}








return 0;
}
}
}

but i cant execute my output can ou help me again plss.....

hence im new in this kind of program
well:-/ let's say, that this program is totally bad...
maybe than repairing it, you should read some more tutorials, because in this style you hardly create a functional program. I'm learning from books, and I thing it's better than internet tutorials (just my personal opinion). And if I can give you advice, don't buy books like "Learn C++ in 24 hours", and so. C++ is very complex and difficult language, so you better buy something 'big':-). Good luck
And about that program, I think you were trying to do something like this?:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
using namespace std;
int main ()
{
	int age = 0;
	char citizen = '\0';

	cout << "Enter your age: ";
	while (!(cin >> age))
	{
		cin.clear();
		cin.ignore(100, '\n');
		cout << "No sir, please enter your age (number): ";
	}

	if (age >= 18)
	{
		cout << "Are you filipino citizen?(y/n): ";
		cin >> citizen;
		if (citizen == 'y' || citizen == 'Y')
			cout << "You are eligible to vote\n";
		else
			cout << "\nYou are not eligible to vote\n";
	}
	else
		cout << "You are not eligible to vote\n";
	system ("PAUSE");
	return 0;
}
thank you thank you very much.i dont know how to repay your so good in this kind of program ..thank you .............
-ismael B.
Topic archived. No new replies allowed.