[Show all top banners]

dhamilo_chitiz
Replies to this thread:

More by dhamilo_chitiz
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Plz help with C program
[VIEWED 4303 TIMES]
SAVE! for ease of future access.
Posted on 11-10-06 9:51 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

This program always gives the following output: it's making me sick. plz help debugging

hw5.c: In function `main':
hw5.c:25: warning: passing arg 1 of `search' makes pointer from integer without a cast

The program is about resistors marked with colored bands. It asks for the colors of the bands. The first two bands give the digits of the first two number and the third is a power of ten multiplier.

This is my sick program:(I think the correspondence between the first arguments when i call the function, and the first argument of the function is not matching but don't know how to fix it)

#include
#include
#include

int search(char COLOR_CODES[][], int n, char target[7]);

int
main(void)
{

char COLOR_CODES[10][7] = {"black", "brown", "red", "orange", "yellow", "green", "violet", "gray", "white"};
char user_color[3][7];
int i;
double resistance;
int color_number[3];

printf("Enter the colors of the resistor's three bands, beginning with the band nearest\n");
printf("the end. Type the colors in lowercase letters only, NO CAPS.\n\n");

for (i=0; i<=2;i +=1)
{
printf(" Band %d =>", i+1);
scanf(" %s", user_color[i]);
color_number[i+1] = search(COLOR_CODES[10][7], 10, user_color[i]);
printf("\ncolor no check it is %d", color_number[i+1]);
}



resistance = ((color_number[1]*10 + color_number[2])* pow(10, color_number[3]))/1000 ;
printf(" Resistance value: %f kilo-ohms\n\n\n", resistance);

}

int
search(char COLOR_CODES[][], int n, char target[7])
{
int i;

for (i=0; i<=(n-1) ; i +=1)
{
if (strcmp(COLOR_CODES[i],target[7])== 0)
return(i);
}


}
 
Posted on 11-11-06 12:37 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

you have not declared more than 9 color and u r passing the argumment of the 11th row.
char COLOR_CODES[10][7] = {"black", "brown", "red", "orange", "yellow", "green", "violet", "gray", "white"};


color_number[i+1] = search(COLOR_CODES[10][7], 10, user_color[i]);
 
Posted on 11-11-06 12:47 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

you r not using array properly
 
Posted on 11-11-06 12:48 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

int color_number[3];



resistance = ((color_number[1]*10 + color_number[2])* pow(10, color_number[3 ????]))/1000 ;
 
Posted on 11-11-06 12:49 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

where is return for main

#include
#include
#include ?????????????
 
Posted on 11-11-06 12:52 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

char COLOR_CODES[10][7] = {"black", "brown", "red", "orange", "yellow", "green", "violet", "gray", "white"};




color_number[i+1] = search(COLOR_CODES[10 ??????][7 ????????], 10, user_color[i]);
 
Posted on 11-11-06 1:03 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

send me the assignment and code you have coded so far let me c if i can help u out. fyanl@yahoo.com
 
Posted on 11-11-06 1:04 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 365 days
Recommended Popular Threads Controvertial Threads
शीर्षक जे पनि हुन सक्छ।
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
What are your first memories of when Nepal Television Began?
Sajha Poll: नेपालका सबैभन्दा आकर्षक महिला को हुन्?
ChatSansar.com Naya Nepal Chat
NRN card pros and cons?
TPS Re-registration case still pending ..
Basnet or Basnyat ??
TPS Re-registration
निगुरो थाहा छ ??
Nas and The Bokas: Coming to a Night Club near you
Toilet paper or water?
Anybody gotten the TPS EAD extension alert notice (i797) thing? online or via post?
अमेरिकामा छोरा हराएको सूचना
ढ्याउ गर्दा दसैँको खसी गनाउच
Sajha Poll: Who is your favorite Nepali actress?
Problems of Nepalese students in US
nrn citizenship
TPS EAD auto extended to June 2025 or just TPS?
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
Nas and The Bokas: Coming to a Night Club near you
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters