• Skip to primary navigation
  • Skip to content

Ammar Ali

What's tagline?

  • The Story Of Me
  • Facts About Me
  • The Blog
  • Got a Question?

CPP, Programming / December 27, 2017

Simple C++ OOP Program To Get and Show Car Details

A very basic C++ program using OOP concepts to get and show car details from user..


#include 
#include 
#include 

using namespace std;

class car{
private:
	char name[30];
	char color[20];
	double year;
	long price;
public:
	car(){
		cout << "\n\t Welcome to CAR SHOWROOM! \n";
	}

	void getcar(){
		cout << "\n\t Enter car name:";
		gets_s(name);
		cout << "\n\t Enter color:";
		cin >> color;
		cout << "\n\t Enter year make:";
		cin >> year;
		cout << "\n\t Enter car price:";
		cin >> price;

	}

	void showcar(){

		cout << "\n\t Car name:" << name;
		cout << "\n\t Car year:" << year;
		cout << "\n\t Car price:" << price;
		cout << "\n\t Car color:" << color;
		cout << endl;
	}
};

void main() {
	car c;
	c.getcar();
	c.showcar();
	system("pause");

}

Filed Under: CPP, Programming

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2021 · Ammar Ali