Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 16-08-2007, 10:29 PM   #1 (permalink)
Hey here is the aks
 
arunks's Avatar
 
Join Date: Jan 2006
Location: punjab
Posts: 801
Default Guys help me in C

Guys plz tell me how to make a program in C to print like this....

____1
___12
__123
_1234
12345
_1234
__123
___12
____1

all the underscores or lines are just blank spaces.i have to print only numerals
Plz help me..i m in little hurry


plz help me and any body plz tell me in C what is the maximum variable name length size limit.. In some books it is written only 8 characters but in some book i is written 32 and in another it is written 247 characters.... I wanna know what does real C supports .... actually we always write and execute C program in turbo C++ compiler so according to me there is different limits on maximum lenght of a variable name by turbo c and turbo c++ compiler... So plz tell me what is that
__________________
yours truly
arun
The aks!!

have a nice day

Last edited by arunks; 16-08-2007 at 10:46 PM.
arunks is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 16-08-2007, 10:39 PM   #2 (permalink)
18 Till I Die............
 
Join Date: Jul 2004
Location: India, Mumbai, Marine Lines
Posts: 5,792
Default Re: Guys help me in C

In hurry to submit your homework?
mehulved is offline  
Old 16-08-2007, 10:46 PM   #3 (permalink)
In The Zone
 
Pragadheesh's Avatar
 
Join Date: Jul 2006
Location: Coimbatore
Posts: 403
Post Re: Guys help me in C

this is easiest pgm possible....

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the value of n: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d\t",j);
}
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d\t",j);
}
printf("\n");
}
getch();
}
Pragadheesh is offline  
Old 16-08-2007, 10:52 PM   #4 (permalink)
Hey here is the aks
 
arunks's Avatar
 
Join Date: Jan 2006
Location: punjab
Posts: 801
Default Re: Guys help me in C

ya plz help me and any body plz tell me in C what is the maximum variable name length size limit.. In some books it is written only 8 characters but in some book i is written 32 and in another it is written 247 characters.... I wanna know what does real C supports .... actually we always write and execute C program in turbo C++ compiler so according to me there is different limits on maximum lenght of a variable name by turbo c and turbo c++ compiler... So plz tell me what is that

Quote:
Originally Posted by Pragadheesh
this is easiest pgm possible....

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the value of n: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d\t",j);
}
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d\t",j);
}
printf("\n");
}
getch();
}

thanx for fast reply and thanx for ur program but that program displays this



1
12
123
1234
12345
1234
123
12
1


but i want this
____1
___12
__123
_1234
12345
_1234
__123
___12
____1

plz see again
__________________
yours truly
arun
The aks!!

have a nice day

Last edited by arunks; 16-08-2007 at 10:52 PM. Reason: Automerged Doublepost
arunks is offline  
Old 16-08-2007, 11:19 PM   #5 (permalink)
NP : Crysis
 
xbonez's Avatar
 
Join Date: Mar 2007
Location: City 17
Posts: 1,415
Default Re: Guys help me in C

here this will give proper ouput.

but it is C++. u just need to tweak it a little bit. replace the cout and cin commands with printf and scanf respectively

Code:
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int i,j,n;
	cout<<"\n\nEnter limit-->\t";
	cin>>n;

	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n-i;j++)
			cout<<" ";
		for (j=1;j<=i;j++)
			cout<<j;
		cout<<endl;
	}

	for (i=1;i<=n;i++)
	{
		for (j=1;j<=i;j++)
			cout<<" ";
		for (j=1;j<=n-i;j++)
			cout<<j;
			cout<<endl;
	}
	getch();
}
__________________
Gaming: Phenom II x4 965BE @ 3.6Ghz/Corsair H50 Liquid Cooling/MSI 790FX-GD70/2x2GB GSkill Ripjaws 7-7-7-24/3 x GTX 470 w/Zalman VF3000F/Corsair 850W PSU/Antec 1200/2xSpinpoint F3 500Gb RAID 0
xbonez is offline  
Old 17-08-2007, 12:09 AM   #6 (permalink)
Hey here is the aks
 
arunks's Avatar
 
Join Date: Jan 2006
Location: punjab
Posts: 801
Default Re: Guys help me in C

@xbonez
thank you very much..ur code is working correct...


but guys what abt my other question abt variable length size maximum in c
__________________
yours truly
arun
The aks!!

have a nice day
arunks is offline  
Old 17-08-2007, 12:14 AM   #7 (permalink)
Banned
 
slugger's Avatar
 
Join Date: May 2004
Location: Baudland
Posts: 2,430
Default Re: Guys help me in C

all those who r giving away the proper code should realise that by doing so you r in no way helping the thread starter acquire proficiency in programming

let d thread starter first try to do it and show it 2 us and then v cud help him out by pointing out where he is going wrong, instead of blindly giving away d code
slugger is offline  
Old 17-08-2007, 12:49 AM   #8 (permalink)
Apprentice
 
nightcrawler's Avatar
 
Join Date: Sep 2006
Location: Mumbai
Posts: 65
Default Re: Guys help me in C

Well regarding as to the variable length size i did not get what that means...if it is the variable name length (As in the int num, here num is of length 3) then it depends upon what compiler you use if it is ANSCI C99 based then it is 31 for variables (identifiers) which are external and 63 characters for the internal identifiers. Although if you are using something like gcc or MSVC then you don't need to worry about variable length at all. Rest assured the length is a relatively big number.

If on the other hand what you mean is bit length of a variable (data type assumed is an int) then on almost all modern compilers(and hence modern systems an int is treated as long int that is 4 bytes and not 2 bytes as used to be the case earlier.

And I suggest you should really try and write your own programs and not ask for them if you really want to do something in programming....and also try and lookup for answers for questions like that of yours. Googling for answers(and not for code) is a good option

Best Luck
__________________
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.
nightcrawler is offline  
Old 17-08-2007, 05:32 PM   #9 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
Default Re: Guys help me in C

If u r talking abt the Data type wise length, then use "sizeof" operator.

ex.
Code:
void main()
{
     int a;
     float b;
     
     printf ("Size of Interger is : %d", sizeof(a));
     printf ("\nSize of Float is : %d", sizeof(b));
   
     getch();
}
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 11-09-2007, 01:52 PM   #10 (permalink)
s,b+..u cn..
 
nikhil ramteke's Avatar
 
Join Date: Dec 2006
Posts: 76
Default Re: Guys help me in C

Quote:
Originally Posted by slugger
all those who r giving away the proper code should realise that by doing so you r in no way helping the thread starter acquire proficiency in programming

let d thread starter first try to do it and show it 2 us and then v cud help him out by pointing out where he is going wrong, instead of blindly giving away d code
exectly!!!!!!!!this will inovate the mindset of the programmers...and DIGITERS also!!!
nikhil ramteke is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please guys help me Sonali jain Software Q&A 3 31-08-2006 07:32 PM
Just look it guys Third Eye Gamerz 4 07-08-2006 10:18 PM
NEED A LITTLE HELP GUYS... Slam Team QnA (read only) 12 16-06-2005 05:29 AM
939 or 754...what u guys think?? parimal QnA (read only) 2 31-01-2005 01:26 PM


All times are GMT +5.5. The time now is 05:15 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2