473,385 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Small question! Why doesn't this print what I want it to print!

64
This is the code I have so far. I want it to print it in different order like you can probably see below. But when I actually see the results it gives me different numbers. It gives me this after I type 10 numbers in...2293620 22935842293616 22935882293612 22935922293608 22935962293604 2293600

Here is my code so far maybe you guys can tell me what I did wrong...

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3.  
  4. int main (void) 
  5. {
  6. //    Local Declarations 
  7.     int a;
  8.     int b;
  9.     int c;
  10.     int d;
  11.     int e;
  12.     int f;
  13.     int g;
  14.     int h;
  15.     int i;
  16.     int j;
  17.  
  18. //    Statements 
  19.     printf("Please enter 10 numbers\n");
  20.     scanf("%d %d %d %d %d %d %d %d %d %d",&a,
  21.     &b,&c,&d,&e,&f,&g,&h,&i,&j);
  22.     printf("%3d %3d",&a,&j);
  23.     printf("%3d %3d",&b,&i);
  24.     printf("%3d %3d",&c,&h);
  25.     printf("%3d %3d",&d,&g);
  26.     printf("%3d %3d",&e,&f);
  27.  
  28.     return 0;
  29. }   //  main 
  30.  
  31.  
  32.  
Jan 18 '07 #1
1 1163
This is the code I have so far. I want it to print it in different order like you can probably see below. But when I actually see the results it gives me different numbers. It gives me this after I type 10 numbers in...2293620 22935842293616 22935882293612 22935922293608 22935962293604 2293600

Here is my code so far maybe you guys can tell me what I did wrong...

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3.  
  4. int main (void) 
  5. {
  6. //    Local Declarations 
  7.     int a;
  8.     int b;
  9.     int c;
  10.     int d;
  11.     int e;
  12.     int f;
  13.     int g;
  14.     int h;
  15.     int i;
  16.     int j;
  17.  
  18. //    Statements 
  19.     printf("Please enter 10 numbers\n");
  20.     scanf("%d %d %d %d %d %d %d %d %d %d",&a,
  21.     &b,&c,&d,&e,&f,&g,&h,&i,&j);
  22.     printf("%3d %3d",&a,&j);
  23.     printf("%3d %3d",&b,&i);
  24.     printf("%3d %3d",&c,&h);
  25.     printf("%3d %3d",&d,&g);
  26.     printf("%3d %3d",&e,&f);
  27.  
  28.     return 0;
  29. }   //  main 
  30.  
  31.  
  32.  

You are passing the pointer to the integers.

Try using:
printf("%3d %3d",a,j);

(and likewise) instead
Jan 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Thomas Weholt \( PRIVAT \) | last post by:
I've got a rather small project, small in the sense that there's not a lot of different tables needed in the database/storage-system, but there will be alot of data and the clients must be able to...
3
by: Nickolay | last post by:
it's easy to create small executable from python code, when using assembler compilers. I ask you if need it?
7
by: Sharon | last post by:
Hiya I have a small question, I saw this piece of code somewhere (it's for creating a customized context menu) and I was wondering: Why is it that the STYLE and SCRIPT-tags are broken up into...
3
by: Tim | last post by:
Hi Group, Apologies if this is a bit OT (if so, please advise where it should be posted). I was wondering if anyone had any ideas as to what applications could work in a system where the...
5
by: Geoff Cox | last post by:
Hello Would be grateful if someone can make a few things clear for me! I have developed a small app using Java and would like to do the same using C++ but without the need for a runtime...
1
by: Gena | last post by:
Hi , I'm a newbe to programming and have a small question: I made a small program with a class. in the class's header file I have : double *ptr_output; Void main() { double result;
4
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
When one architects a new project one of the first steps in the decision is to decide on the layers. (In my opinion anyway) One architecture that I have used before is to go solid OO and create...
1
by: =?Utf-8?B?cmJiZW5zb24=?= | last post by:
To begin,, the network infactructure- Servers - Server00 - Windows Server 2003/Installed Server01 - Windows Server 2003/plan to install Server10 - Linux RedHat Workstation/Installed ...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
1
by: mbatestblrock | last post by:
I know this is a completely out there question with a million open ended questions. I was just hoping I could get a round about answer... Using a basic form: EX: name, address, phone number. etc...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.