Guys help me in C

Status
Not open for further replies.

arunks

Hey here is the aks
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
 
Last edited:

Pragadheesh

In the zone
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();
}
 
OP
arunks

arunks

Hey here is the aks
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

Pragadheesh said:
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
 
Last edited:

xbonez

NP : Crysis
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();
}
 
OP
arunks

arunks

Hey here is the aks
@xbonez
thank you very much..ur code is working correct...


but guys what abt my other question abt variable length size maximum in c
 

slugger

Banned
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
 

nightcrawler

Broken In
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
 

Garbage

God of Mistakes...
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();
}
 

nikhil ramteke

s,b+..u cn..
slugger said:
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!!!
 
Status
Not open for further replies.
Top Bottom