 |
|
21-02-2005, 10:38 PM
|
#1 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
[Help] C Programming
I need to write some programs in C Language that will Print the
Following Outputs:
I]
@@@@
*@@@
**@@
***@
II]
@@@@@@@@@@
@@@@***@@@@
@@@******@@@
@@*********@@
@************@
III]
******@
*****@@
****@@@
***@@@@
Note that only the @ symbols need to be printed.Only loops like For,While
& If...Else are Permitted.Any Help will be highly apppreciated.......
No matter How hard i've tried,I could'nt figure out how to do it.
I heard that the Digit Family is a very Helpful one when it comes to
newbies.I Sincerely Hope that this message of mine shall not be
Deleted/Banned......Hoping for an early Reply.
Adios...
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
|
Advertisements. Register and be a member of the community to get rid of them.
|
|
Advertisement
|
|
21-02-2005, 10:42 PM
|
#2 (permalink)
|
|
Alpha Geek
Join Date: May 2004
Location: India
Posts: 930
|
I am rather bothered by your username...
Are you a member of the KuKluxKlan?
Or you really appretiate them?
Coz they are virtual terrorists....
|
|
|
21-02-2005, 11:00 PM
|
#3 (permalink)
|
|
Apprentice
Join Date: Sep 2004
Location: Utopia
Posts: 98
|
yeah why KuKluxKlan...i mean even Sherlock Holmes fears them
neways heres my solutions
not tried them out though
hope they work !!
1]
for(i=0;i<4;i++)
{
for(j=0;j<i;j++)
printf(" ");
for(j=0;j<4-i,i++)
printf("@");
printf("\n");
}
2]
for(i=0; i<5;i++)
{
for(j=0;j<5-i;j++)
printf("@");
for(j=0;j<i;j++)
printf(" ");
for(j=0;j<i;j++)
printf(" ");
for(j=0;j<5-i;j++)
printf("@");
printf("\n");
}
3]
for(i=0;i<4;i++)
{
for(j=0;j<4-i;j++)
printf(" ");
for(j=0;j<i+1;j++)
print("@");
printf("\n");
}
I'm assuming the '*' are blank spaces
|
|
|
21-02-2005, 11:07 PM
|
#4 (permalink)
|
|
In The Zone
Join Date: Sep 2004
Location: Chennai
Posts: 353
|
@technovice...
Thot I wud give the answers but see tat ya has given the right answers...
Anyways, my word of appreciation for helping the fella...
__________________
The Bloglines of an Angry Indian -
www.angry-indian.com
If only life were as easy as Ctrl+Z (undo) and F4/Ctrl+Y (redo)...
|
|
|
22-02-2005, 11:54 AM
|
#5 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
Thank you technovice for helping me out with the programs......
I gotta check them out.But I have a problem.I formatted my PC
Recently and do not have the Turbo C Editor.Is there anywhere I can
Download it off the net?
I am a Std X student & Am trying to learn C on my own from some
Books by Yeshwant kanetkar. Until now i had done only simple programs
on my own.But now the going seems tough.
Thank You Once Again For Your Help.
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
22-02-2005, 12:00 PM
|
#6 (permalink)
|
|
Davislav Ivanuiz!!!
Join Date: Apr 2004
Location: Pune
Posts: 1,396
|
__________________
I was here when the forum's swear filter kept bleeping out the word 'FUNK'. :crazy::censored::eeksign:
www.abhi247.com | The Photohblog A Little Lunacy! [v3]
Flickr!
|
|
|
22-02-2005, 12:16 PM
|
#7 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
thank You Kl@w for the link.....I shall try compiling the progs now....
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
22-02-2005, 03:48 PM
|
#8 (permalink)
|
|
Apprentice
Join Date: Sep 2004
Location: Utopia
Posts: 98
|
i have the same problem as you KKK
so im sorry if there are any syntax errors
__________________
A flea and a fly in a flue, were caught, so what could they do? Said the fly, \"let us flee!\" \"Let us fly!\" said the flea. So they flew through a flaw in the flue.
|
|
|
23-02-2005, 04:49 PM
|
#9 (permalink)
|
|
In The Zone
Join Date: Sep 2004
Location: Bermuda Triangle
Posts: 239
|
Quote:
|
Originally Posted by Kl@w-24
|
From where can I download the Turbo C++ compiler,plz?
|
|
|
23-02-2005, 10:07 PM
|
#10 (permalink)
|
|
Davislav Ivanuiz!!!
Join Date: Apr 2004
Location: Pune
Posts: 1,396
|
__________________
I was here when the forum's swear filter kept bleeping out the word 'FUNK'. :crazy::censored::eeksign:
www.abhi247.com | The Photohblog A Little Lunacy! [v3]
Flickr!
|
|
|
24-02-2005, 12:17 AM
|
#11 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Location: GOA INDIA
Posts: 59
|
BETTER THAN ASKING
I WOULD WANT U TO GO FOR A C PGMMING TUTORIAL
BUT WHY DO U REQUIRE THESE??
|
|
|
28-02-2005, 12:49 PM
|
#12 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
Thanx a lot Guys....
That made my programming easier...
though i still am in the dark regarding Functions n NEsted Functions...
any tutorials?
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
01-03-2005, 10:57 AM
|
#13 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
What do you want to know about functions? Let us know. May be we can help
What do you mean by nested functions? Or is it nested loops?
But I think you are already referring to a book by Kanetkar. Does it not explain enough?
BTW, you have a deadly username!!  KuKluxKlan!! What a name!!
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
|
|
|
01-03-2005, 01:33 PM
|
#14 (permalink)
|
|
Broken In
Join Date: Jan 2004
Location: /bin/sh
Posts: 158
|
thats a crazy nick! hope you aint like em(the klan!)
dude go to http://www.programmersheaven.com
you ll get all the tutorials and tools you need.
|
|
|
02-03-2005, 06:40 AM
|
#15 (permalink)
|
|
Apprentice
Join Date: Mar 2004
Location: Pune
Posts: 64
|
great link lammy
thanx alot
__________________
AMD Athlon 64-2800@ 2.4 Ghz,Asus K8N,2X1GB DDR400 Transcend Memory @2.5-3-3-5,Segate 160GB PATA,LG GSA-H10N,BBA X800 XT PE,Windows XP+SP2,Vista Ultimate,Ubuntu 6.10,Altec Lansing ATP3,Philips SHP805
|
|
|
02-03-2005, 12:04 PM
|
#16 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
Quote:
|
Originally Posted by sagar_mutha
great link lammy
thanx alot 
|
I second that.  Great link.
|
|
|
02-03-2005, 01:03 PM
|
#17 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
Quote:
|
Originally Posted by lamnirmal
thats a crazy nick! hope you aint like em(the klan!)
|
Not at all
Jus' that I tried 2-3 Variations of My name(which is a Quite Common One)
and was disappointed-There were already used.....So Thot of this Unique one
Quote:
|
Originally Posted by lamnirmal
|
Thanx for that Link......I read some and were helpful....
But can I download them as eBooks? or any other Way???
Quote:
|
Originally Posted by tuxfan
What do you want to know about functions? Let us know. May be we can help
|
Functions are Somewhat Easy.....Just the Nested ones have me in a Tizzy
Quote:
|
Originally Posted by tuxfan
What do you mean by nested functions? Or is it nested loops?
|
Nested Functions=Functions Within Functions.....They're a bit confusing...
Particularly the ones with many nestings.....
Quote:
|
Originally Posted by tuxfan
But I think you are already referring to a book by Kanetkar. Does it not explain enough?
|
Yeah..It helps...but There's
No One to Xplain to me....i'm all on my own.....
Quote:
|
Originally Posted by tuxfan
BTW, you have a deadly username!! KuKluxKlan!! What a name!!
|
Thanxxx for the Appreciation......
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
02-03-2005, 09:53 PM
|
#18 (permalink)
|
|
Wise Old Owl
Join Date: Feb 2004
Location: Palghar, Mumbai
Posts: 1,000
|
Quote:
|
Originally Posted by KuKluxKlan
Quote:
|
Originally Posted by tuxfan
What do you want to know about functions? Let us know. May be we can help
|
Functions are Somewhat Easy.....Just the Nested ones have me in a Tizzy
Quote:
|
Originally Posted by tuxfan
What do you mean by nested functions? Or is it nested loops?
|
Nested Functions=Functions Within Functions.....They're a bit confusing...
Particularly the ones with many nestings.....
|
What are those NESTED FUNCTIONs ?
__________________
i generally prefer quality over quantity
1 aadi + 1 aadi = 1 full ;)
|
|
|
02-03-2005, 10:44 PM
|
#19 (permalink)
|
|
Technoholik !!
Join Date: Oct 2004
Location: Bangalore
Posts: 1,308
|
dude the book by Yeshwant kanetkar is pretty good one there , even we had used it during our early college days. Why don't u try book meant for new programmers, like book by DUMMIES --- C++ Programming For Dummies 3rd Edition by Stephen R. Davis, it a good book for starters.
__________________
[Desktop]
[CPU] Intel C2D 2.4Ghz || [RAM] 2GB DDR2 || [VDU] Samsung P2370MS 23”|| [HDD] 500GB Seagate 7200RPM SATA || [OS] Mac OS X (Hackintosh)
[Laptop]
Dell Studio 15 Full HD || [OS] Now with Mac OS X LION :-D
|
|
|
03-03-2005, 12:49 AM
|
#20 (permalink)
|
|
Broken In
Join Date: Jan 2004
Location: /bin/sh
Posts: 158
|
dude KuKlux pm me your email .... i ll host a few ebooks on C on a hosting server where you can download em off........or just search the forum....there are quite a lot of links to ebook sites(all legal!)
about nested functions............hope the below code clears your confusion.
imagine of a traveller moving to the different countries from main and when hes in australia() he doesnt go to anyother place(cause australia() doesnt call any function) and thus to find his way back to main he climbs up the way he came down.........
Code:
void india();
void england();
void usa();
void australia();
void main()
{
printf(" i am in main");
india();
printf("jus got back from india!.......finally here...what a ride");
}
void india()
{
printf("im in india! ");
england();
printf("jus got back from england.....!");
return;
}
void england()
{
printf("im in england.......the queen aint hot!");
usa();
printf("jus got back from usa");
return;
}
void usa()
{
printf("im in usa......so whats so great bout this place?pathetic!");
australia();
printf("got back from australia");
return;
}
void australia()
{printf("lost in the outbacks!.....gotta find myself way back");
return;
}
your output would be.....
i am in main
im in india!
im in england.......the queen aint hot!
im in usa......so whats so great bout this place?pathetic!
lost in the outbacks!.....gotta find myself way back
got back from australia( now you are in usa)
jus got back from usa(now in england)
jus got back from england.....!(now in india)
jus got back from india!.......finally here...what a ride(home sweet main.....program ends
|
|
|
03-03-2005, 12:50 AM
|
#21 (permalink)
|
|
In The Zone
Join Date: Feb 2004
Location: Kerala
Posts: 405
|
Hi Klux
which book u r using?? Let us C?
There is no nested functions in C as u 've mentioned.
u may be mentioning something like this.
main()
{
a();
}
a()
{
b();
}
b
{
c();
}
c()
{
}
are u mentioning this type of function call?????
__________________
Quitters Never Win & Winners Never Quit!
|
|
|
03-03-2005, 12:53 AM
|
#22 (permalink)
|
|
In The Zone
Join Date: Feb 2004
Location: Kerala
Posts: 405
|
if u ve that program - the one with nested functions - pls post it here.
Let Us C is a good book (u may skip some advanced topics which is discussed on that book)
then Pointers in C
then Projects in C
then TSR programming thru C
__________________
Quitters Never Win & Winners Never Quit!
|
|
|
03-03-2005, 02:05 PM
|
#23 (permalink)
|
|
Wise Old Owl
Join Date: Feb 2004
Location: Palghar, Mumbai
Posts: 1,000
|
Quote:
|
Originally Posted by lamrinnirmal
dude KuKlux pm me your email .... i ll host a few ebooks on C on a hosting server where you can download em off........or just search the forum....there are quite a lot of links to ebook sites(all legal!)
about nested functions............hope the below code clears your confusion.
imagine of a traveller moving to the different countries from main and when hes in australia() he doesnt go to anyother place(cause australia() doesnt call any function) and thus to find his way back to main he climbs up the way he came down.........
Code:
void india();
void england();
void usa();
void australia();
void main()
{
printf(" i am in main");
india();
printf("jus got back from india!.......finally here...what a ride");
}
void india()
{
printf("im in india! ");
england();
printf("jus got back from england.....!");
return;
}
void england()
{
printf("im in england.......the queen aint hot!");
usa();
printf("jus got back from usa");
return;
}
void usa()
{
printf("im in usa......so whats so great bout this place?pathetic!");
australia();
printf("got back from australia");
return;
}
void australia()
{printf("lost in the outbacks!.....gotta find myself way back");
return;
}
your output would be.....
i am in main
im in india!
im in england.......the queen aint hot!
im in usa......so whats so great bout this place?pathetic!
lost in the outbacks!.....gotta find myself way back
got back from australia( now you are in usa)
jus got back from usa(now in england)
jus got back from england.....!(now in india)
jus got back from india!.......finally here...what a ride(home sweet main.....program ends
|
This is not a nested function. Just a simple function calling other function.
__________________
i generally prefer quality over quantity
1 aadi + 1 aadi = 1 full ;)
|
|
|
03-03-2005, 03:46 PM
|
#24 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
Quote:
|
Originally Posted by aadipa
Quote:
|
Originally Posted by lamrinnirmal
dude KuKlux pm me your email .... i ll host a few ebooks on C on a hosting server where you can download em off........or just search the forum....there are quite a lot of links to ebook sites(all legal!)
about nested functions............hope the below code clears your confusion.
imagine of a traveller moving to the different countries from main and when hes in australia() he doesnt go to anyother place(cause australia() doesnt call any function) and thus to find his way back to main he climbs up the way he came down.........
|
This is not a nested function. Just a simple function calling other function.
|
Thanx Nirmal for the prog..I'm sure gonna try it out.
And aadipa a function calling another function is called Nesting of functions.
Atleast I think it is...Please correct me If I'm wrong.
As in case of Loop within a loop leads to various iterations.a function
within another function leads to nesting of functions.I have jus stepped
onto Recursions and they make my head go ga-ga
And Hafees.....the Book I'm presently referring to is Programming in C
By Venugopal & Prasad a/w the Kanetkar & Balagurusamy ones.....
|
|
|
03-03-2005, 04:31 PM
|
#25 (permalink)
|
|
Broken In
Join Date: Jan 2004
Location: /bin/sh
Posts: 158
|
@aadipa- the poster has defined nested functions in his post as:
Quote:
Nested Functions=Functions Within Functions.....They're a bit confusing...
Particularly the ones with many nestings.....
|
since every function called from any other function returns back to the point where it was called a nest is formed is'nt it?.........
anyways i made up the program reading his post as he has defined...... if im wrong let me know pal....
|
|
|
04-03-2005, 10:37 AM
|
#26 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
Ok. So the confusion is cleared about what is nested function. Actually, there is nothing called nested function. There may be nested loop. For example
Code:
while (TRUE)
{
some code.... ;
for (x=1; x<=20; x++)
{
some code .... ;
}
}
These functions calling another function is pretty simple. Tell us what you don't understand about them.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
|
|
|
08-03-2005, 11:36 AM
|
#27 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
Quote:
|
Originally Posted by tuxfan
Ok. So the confusion is cleared about what is nested function. Actually, there is nothing called nested function. There may be nested loop. For example
Code:
while (TRUE)
{
some code.... ;
for (x=1; x<=20; x++)
{
some code .... ;
}
}
These functions calling another function is pretty simple. Tell us what you don't understand about them.
|
Yeah I pretty much understand what the nesting of loops is all about...
But u ce ethe thing with functions is that they return to where it was called
from after performing the task.That is where I get into a mess....
For eg..I call a function at line 6 of my prog....It goes to its definition
which i have provided at the end,carrieds out the task & returns back
to line 7 and then the prog continues....
WIth nesting of functions,it becomes complicated.....If suppose there is
a function within the definition of the earlier function,where does it go to
after it gets executed? Back to the Definition part or the Earlier function
called part??
Also what do u mean when u say " A Function returns with a value"?
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
09-03-2005, 01:36 AM
|
#28 (permalink)
|
|
In The Zone
Join Date: Feb 2004
Location: Kerala
Posts: 405
|
Actually y do u use the term nested function like nested if or nested loops. Actually u CAN'T define a function inside another function body.
A function returns to from where it is called. If A calls B and B calls C and C calls D, then D is returned to C and C is returned to B and so on. In no way D can return to A(unless D is called from A).
Return with a value means a function is not void.
By default every function is supposed to return an int
that is
myfunc() is same as int myfunc()
.if u want to make it return nothing then make it void
eg: void my_func(int x) { ... }
A function can return only one value.
__________________
Quitters Never Win & Winners Never Quit!
|
|
|
09-03-2005, 01:15 PM
|
#29 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
Quote:
|
Originally Posted by prasadzmultiplex
Yeah I pretty much understand what the nesting of loops is all about...
But u ce ethe thing with functions is that they return to where it was called
from after performing the task.That is where I get into a mess....
|
If this doesn't happen, you will be in a bigger mess  Where do you think should it go after the function is finished? Just think, what will make it convenient?
Quote:
|
Originally Posted by prasadzmultiplex
For eg..I call a function at line 6 of my prog....It goes to its definition which i have provided at the end,carrieds out the task & returns back to line 7 and then the prog ontinues....
|
This is called sequential programming as compared to event based programming. Usually (not a rule), under GUI, event based programming is used and under text based environments sequential programming is used.
Quote:
|
Originally Posted by prasadzmultiplex
WIth nesting of functions,it becomes complicated.....If suppose there is a function within the definition of the earlier function,where does it go to after it gets executed? Back to the Definition part or the Earlier function called part??
|
Huh?? What are you trying to ask? Control is never returned back the statement that defines a function. It is always retuned to the statement that calls it.
Quote:
|
Originally Posted by prasadzmultiplex
Also what do u mean when u say " A Function returns with a value"?
|
Take a very simple example. You have a function called Add3Numbers(). This is how you call it. Here the function returns a value.
Code:
Sum1 = Add3Numbers(23,12,34);
Sum2 = Add3Numbers(num1,num2,num3);
This function will be coded like this.
Code:
int Add3Numbers (int a, int b, int c)
{
int total;
total = a + b + c;
return (total);
}
Hope you have understood.
|
|
|
11-03-2005, 10:00 PM
|
#30 (permalink)
|
|
Apprentice
Join Date: Feb 2005
Posts: 52
|
Thanxx a lot Tuxfan & hafees.....I seem to have got Functions and their nesting
all taped out.As tuxfan explained,the 'Returning' part was a bit foggy 4 me and
thanx to u & some books/tutorials,i seem to have grasped them.
Now I hate bothering u guys again but I have hit a wall again.This time
its the arrays.I have seen some tutorials as supplied by nirmal and they're good.
But there are no programs on the net are there? Googling is os little use.
I have managed most of the programs given in the exercise but two of them
are eating my head away.
1)A Prog to accept data in2 an array so that Even nos. go into Even
Indexes & odd nos. go into Odd Indexes.
2)A Prog to enter data into a 3X3 matrix so that 1st data goes into 9th
cell,2nd into 8th & so on.....
__________________
I\'m a Racist........Fav Racer is Lance Armstrong :mrgreen:
I\'m a Fascist.......Fav Face is Aishwarya Rai :mrgreen:
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|