If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Compiler

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-18-04, 19:27
Malek Malek is offline
Registered User
 
Join Date: May 2004
Posts: 1
Compiler

Pls if someone can compile me this program and check if it works since i need to send it now to a company because i don't have a compiler at home . I would be grateful
thanks


#include <stdio.h>
#include <stdlib.h>

// For examle the user is to enter an integer



main() {

int sum=0;
int number;
int i;
int mask=1;

printf("Please enter an integer\n");
scanf("%d", number);

for (i=0; i< sizeof(int); i++) {
if ( number & mask ) sum++;
mask << 1;
}

printf("The number of ones in %d is %d", number, sum);

}
Reply With Quote
  #2 (permalink)  
Old 05-18-04, 23:25
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
You really need to take this one into school and try it yourself. There are two minor syntax errors, one logic error, and one just plain old boo-boo. You've got the right idea though!

-PatP
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On