English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

what is the dev c++ solution, that has an array max of 40 elements..the input should be from 0 to 9 only....and output the number according to its place value,, it shoud have a comma for each of the proper place value, the input should be outputed from up to down,,,,

here is the output:

Enter size: 4
4
0
9
6
Result: 4,096 (it should contain the comma (","),if it is greater than hundreds that pertains to its proper place value)

another example:
Enter size: 3
1
2
3
result: 123

another ex. hehehe:
Enter size:7
1
2
3
4
5
6
7
result: 1,234,567

2007-01-21 18:31:48 · 3 answers · asked by Edrew c 2 in Computers & Internet Programming & Design

3 answers

Hi Edrew,
Here is the MORE ACCURATE SOLUTION to your problem.
It will remove the shortcomings of the solution given by dear "iyiogrenci" just above my answer..


main()
{
int a[40];
int i,r,c,n;

printf("Enter total elements to be entered (1-40) : ");
scanf("%d",&n);

for(i=1;i<=n;i++)
{
printf("Enter element a[ %d ]=",i);
scanf("%d",&a[i]);
}

printf("\n\n");

if(n<=3)
for(i=1;i<=n;i++)
printf("%d",a[i]);
else
{
r=n % 3;
if (r != 0)
{
for (i=1;i<=r;i++)
{
printf("%d",a[i]);
}
printf(",");
}

c=n/3;

for(i=1;i<=c;i++)
{printf("%d%d%d",a[r+1],a[r+2],a[r+3]);
r=r+3;
if(i!=c)
printf(",");
}
}
}

.
.

2007-01-24 04:26:11 · answer #1 · answered by Anonymous · 0 0

How many times.... DEV C++ IS NOT A LANGUAGE!!!
C++ is the language you are coding in. Dev C++ is just an editor - you might as well ask "what is the Notepad C++ program for...". To my knowledge this will be the third time I have informed you of this fundamental fact.

2007-01-22 04:03:53 · answer #2 · answered by Anonymous · 0 0

#include
#include

main() {
int a[40];
int x,k,i,r,c,n;

printf("n=%",n);
scanf("%d",&n);

for(x=1;x<=n;x++) {
printf("a[ %d ]=",x);
scanf("%d",&a[x]);

}

printf("\n\n");
r=n % 3;
if (r != 0) {

for (i=1;i<=r;i++)
{printf("%d",a[i]);
}
printf(",");
}

c=n/3;

for(k=1;k<=c;k++)
{printf("%d%d%d",a[r+1],a[r+2],a[r+3]);
r=r+3;
printf(",");
}

printf("\n\n");
system("pause");

}


The output is in the form for n=5
12,345,

how can we delete the last character in the output
using backspace character?

2007-01-22 12:46:50 · answer #3 · answered by iyiogrenci 6 · 0 0

fedest.com, questions and answers