All C/C++ Qurries here

Status
Not open for further replies.

Gurpreet Kaur

Right off the assembly line
Hi

Hi Do anyone know the code in C, C++
which ask for inputting any name say Raj
and after inputting name it gives the message
"Happy Birthday Raj" in a lot of windows??
if anyone know could you please tell me
actually i am a new user and learning C, c++
i am no expert so i can't make suh types of code.
please tell me if you know...thanks
 

praka123

left this forum longback
Am trying to learn C in GNU/Linux(gcc/Anjuta) someone help me link to a good tutorial...Thanks./Consider me as a absolute beginner(diot)
 
OP
Maverick340

Maverick340

Ambassador of Buzz
Re: Hi

Gurpreet Kaur said:
...it gives the message
"Happy Birthday Raj" in a lot of windows??
...
If u r using C++ in the dos version ie Turbo C++ 3.0 or before then u can not do it as DOS dosent supoort windows ..HOwever if u want a repeated statement like output use a for loop
Code:
void main()
{
    char name[10];
    cout<<"Enter your name : ";
    getlinen(name);
      for( int i =0 ;i!=\0;i++)
      cout<<"HAppy Birthday<<name<<"\n";
}

int the for loop (for(int i=0;i<10;i++))
u can give i<//any number u like..the stament will be printed that many times//
 

puja399

In the zone
Re: Hi

Maverick340 said:
..HOwever if u want a repeated statement like output use a for loop
Code:
void main()
{
    char name;
    cout<<"Enter your name : ";
    cin>>name;
      for( int i =0 ;i<10;i++)
      cout<<"HAppy Birthday<<name<<"\n";
}

RU sure this will work??????
I can't get the damn thing to compile even....duhhh....!!!!! :twisted:
And how do I get my whole name within a 'char' ??? How did u do it, using 'cin' ???? :roll: :roll:
 

QwertyManiac

Commander in Chief
Re: Hi

Maverick340 said:
Gurpreet Kaur said:
...it gives the message
"Happy Birthday Raj" in a lot of windows??
...
If u r using C++ in the dos version ie Turbo C++ 3.0 or before then u can not do it as DOS dosent supoort windows ..HOwever if u want a repeated statement like output use a for loop
Code:
void main()
{
    char name;
    cout<<"Enter your name : ";
    cin>>name;
      for( int i =0 ;i<10;i++)
      cout<<"HAppy Birthday<<name<<"\n";
}

int the for loop (for(int i=0;i<10;i++))
u can give i<//any number u like..the stament will be printed that many times//

he asked WINDOWS and u didnt give any, where are the headers... :|
and yeah, how the heck a whole name in a char ???
 
OP
Maverick340

Maverick340

Ambassador of Buzz
eddited

NExt problem:
Write a program to determine the max and min element in an unsorted array with altering the array.
func is :
void extremes(int& max, int& min, int a[ ], int n)
 

sakumar79

Technomancer
The solution to both of Maverick340's problems is easy... Without altering the array, create a copy of it and sort the copy. Now, the smallest/largest, second smallest/largest, etc are just a call by index away...

If you dont want to use a second array, create variables larg,smal,seclarg etc, set them to the first element. Parse the list from second to last and at each stage update the larg,smal,seclarg variables to monitor the largest, smallest, second largest values of the numbers encountered upto that index... At the end, you should have the result.


Regarding Kaur's query for printing Happy Birthday <name> many times:
1. Change the char definition for name to char pointer or String.
2. If printing on screen instead of windows is okay, the cout statement should be
cout<<"Happy Birthday "<<name<<"\n";
A quotation marks was missing.
3. For creating windows, you will need to use graphics libraries which I am not proficient in... Many libraries I think are OS-dependant so you have to be careful and try to choose one that is available readily for all platforms (if you dont need to have cross-platform compatibility, this is not necessary).

Arun
 

mako_123

Ambassador of Buzz
Guys

Currently i use Turbo c++ ( dos one ) for programming in c++ . Now i want to shift to Dev C++ . Can anyone tell me whether there will be any diff in programming in dev c++ and what are its advantages over turbo c++ .
 

puja399

In the zone
mako_123 said:
Guys

Currently i use Turbo c++ ( dos one ) for programming in c++ . Now i want to shift to Dev C++ . Can anyone tell me whether there will be any diff in programming in dev c++ and what are its advantages over turbo c++ .

There r a lot of differences between TC++ and Dev-c++.

First, Dev-c++ is the IDE that uses GNU C++ compiler (MingW version) which is (perhaps) the best C++ compiler available as on today. It supports all the standards of modern C++ (i.e., ISO/ANSI C++). Remember, even the compiler included in the Microsoft Visual C++ doesn't support all of the ISO/ANSI C++ standard. Moreover, its Dev-C++ is free unlike TC++ which is a commercial compiler (although its not supported anymore), obsolete and doesn't support modern C++ standard. What u can do with TC++ is an ancient (prehistoric !!) C++ which is actually worthless nowadays.

Second, Dev-c++ is written for modern 32 bit Windows, u can program for console, Windows GUI, OpenGL, and also easy textbased c++ programs. TC++ on the other hand has a lot of issues while running on WinNT/XP, simply bucuz, its not written for 32 bit windows. TC++ is only 16 bit, and when it was written, WinXP was unimaginable.

The only comparison with TC++ and Dev-C++ that comes to my mind is the one between a bullock curt and a ferrari running on an expressway.

Some are still with TC++ due to graphics prgramming (the BGI thing), but just ask urself, did u notice one single application in the last 5 years that uses BGI?? NO, because its extinct. U can do more and far better graphics with Dev-C++ that with TC++.

So, get rid of TC++, and use DevC++, becuz, otherwise, ur C++ skill (learned with TC++) will become useless in modern world.
 

hpotter606

Journeyman
1. what is a file descripter in C.
There is a fill in the blanks in todays o level 'C' paper.

2. *a is same as a[] in a parameter declaration (true or false)

Can anybody please help me with these questions?
 
Status
Not open for further replies.
Top Bottom