Skip to main content

Enumerated Datatypes AND #define

Ooops..! yes, this is an another post related to OOP.

I feel this is some thing nice. There are situations where we want to introduce new data variables. That's why enumerated data types are used. haha, but this is not like u expect!

Enumerated Datatypes

  • These are user defined datatypes
  • the key-word enum is used
  • syntax is enum var_name{var1,vae2,...,varn};
  • what happens is : var1=0, var2=1, var3=2, var4=3,...
  • try the prog. below in ur cpp compiler.

#define

  • #define key-word is used.
  • Eg: #define x value
  • No ";" is used
  • advantage: for a large program, if we want to alter a constant that is repeatedly used throughout the programme.
  • meaning x can be used insted of value.
For the perfect understanding, please work on the example below.
(Shhhh... it is very simple!)
_____________________________________________

// using enumerated data types, #define

#include<conio.h>
#include<iostream.h>
#define num 60
#define name 0

void main()
{
clrscr();

enum b{q,w,e};

cout<<"num ="<<num<<endl<<"name ="<<name<<endl<<"q="<<q<<"\nw="<<w<<"\ne="<<e<<endl;

getch();
}
____________________________________________

Also note:
  • cout is an output statement
  • endl is used for new line
  • "\n" is also used for new line
If u r with problems/help/comments/corrections, Never Ever forget to share it here! Thank U.

Comments

Popular posts from this blog

Talky Messenger Documentation & Setup

( Github ) Just created a chat app that runs in Node and Socket. the attempt was worthy. Talky is a messenger app built with Node, Express, Socket, Angular & Bootstrap. It's like a server-client structure. (But obviously not like the one we done at OS lab using shared memory). It has a broadcasting structure. Talky does not keep a log on chat. i.e., It doesn't have a memory or database. When we close the browser window, chat history is lost. There I also added a basic console, protected by a password, to send real-time notifications to active clients. The name 'Talky' was suggested by a friend of mine. (hey, thank you for that. The fact is that I am not really good at naming...😝) What if sometimes your college blocks WhatsApp? Try Talky. ( There is also a website on internet in the name of 'Talky' which has no connection with this one. ) Download Talky Messenger To use Talky, all you need is 3 things: Node server Source code...

How to pass variables to res.render() in Node.js

I was trying to figure out how to render a view inside a view, as I was stuck with this issue. Horrible Effects of Misplaced Extensions ;) I was using Node.js platform with ejs template engine. My index.ejs file has an included header.ejs file. Everything works well except that I can't pass values to the variable status in header.ejs. Here is my abstract code... index.ejs header.ejs app.js The most funniest solution ever! The solution is as easy as this. Just remove .ejs extension from the include command. I spent at least an entire night to figure it out.

Connecting Kerala's Call of Duty Warzone Community: Find Your Squad!

Namaskaram f ellow Warzone fanatics! Tired of dropping into Verdansk only to be met with a chorus of confused comms and random grenades? I feel your pain. Finding a squad that speaks your language (literally and figuratively) can be tougher than surviving a gas zone with only a pistol. That's why I've built this little corner of the internet – a rallying point for all the Malayalam-speaking Warzone warriors of Kerala! warzonekerala.com Why Join the Kerala Warzone Group? (More Than Just a Game): Let's face it, Warzone isn't just about shooting and looting. It's about camaraderie, shared victories, and the glorious "poda mone dinesha" moments. Here's why joining our community is a game-changer: Bhasha Bliss: Finally, a squad where you can strategize in crystal-clear Malayalam! No more frantic hand gestures or Google Translate mishaps. Coordinate drops, call out enemies, and celebrate wins in your mother tongue. Kerala Connection: Connect with ...