| | |
help!! problems with loops
![]() |
hi everyone
, i wanted to create a little program with makes the divisions of the elements of a table i wanted to create a loop which will indicate if there's a number in the table then we should c "the division cannot be made", if not we will get the result,the problem is it doesnt work, u may try it n it wont, i know u will say wht is the utility of such stuff, well im just new to C so im tryin with basics,o_O enough talkin here's my source code
plz help me solving this, i spent almost a week thinking about it
thank u for ur help
, i wanted to create a little program with makes the divisions of the elements of a table i wanted to create a loop which will indicate if there's a number in the table then we should c "the division cannot be made", if not we will get the result,the problem is it doesnt work, u may try it n it wont, i know u will say wht is the utility of such stuff, well im just new to C so im tryin with basics,o_O enough talkin here's my source code c Syntax (Toggle Plain Text)
#include<stdio.h> #include<stdlib.h> #include<conio.h> #define n 4 void main() { //variables double table[n]={0}; long no=1,i; double x=0,d; //program for (i=0; i<n; i++) { printf("enter the number %d", i); scanf("%f", &table[i]); } printf("gr8\n"); printf("%f", table[0]/table[1]);//this is just to c if it works for (i=0; i<n; i++) { do { if(x==0) no=0; x=table[i+1]; } while (x!=0); } if (no==0) printf("the division cannot be made"); else d=table[0]/table[1]/table[2]/table[3]; printf("the division is %f", d); system("pause"); }
plz help me solving this, i spent almost a week thinking about it
thank u for ur help
Last edited by Ancient Dragon; Mar 10th, 2008 at 11:01 pm. Reason: removed color tags and added code tags
•
•
Join Date: Jul 2007
Posts: 108
Reputation:
Solved Threads: 7
c Syntax (Toggle Plain Text)
#include<stdio.h> #include<stdlib.h> #include<conio.h> #define n 4 void main() { //variables float table[n]; int no=1,i; float x=0; float d; clrscr(); //program for (i=0; i<n; i++) { printf("Enter the number %d : ", i); scanf("%f", &table[i]); } for (i=0; i<n; i++) { if(x==0 && i!=0) no=0; else x=table[i]; } if (no==0) printf("\nThe division cannot be made"); else { d=table[0]; for(i=1;i<n;i++) d=d/table[i]; printf("\nThe division is %f ", d); } getch(); }
Last edited by Ancient Dragon; Mar 10th, 2008 at 11:01 pm. Reason: add code tags
Why this is bad help:
1) No CODE tags
2) No formatting, code is very difficult to read. See this
3)
4)
5)
6)
barbiegirl,
Please explain what you want in detail. Your explanation is lacking in data necessary to understand your problem. Did you read the post titled Read Me: Read This Before Posting?
1) No CODE tags
2) No formatting, code is very difficult to read. See this
3)
#include<conio.h> -- not portable. Do not use.4)
void main() -- see this5)
clrscr(); -- only 1 compiler defines this function - do not use6)
getch(); -- not portable. Use standard C instead, like getchar() barbiegirl,
Please explain what you want in detail. Your explanation is lacking in data necessary to understand your problem. Did you read the post titled Read Me: Read This Before Posting?
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
•
•
I have given this program only to develop your logic ,it is not a standard form .
IOW, don't help people by showing bad code because it's confusing and does more harm than good. Show an algorithm rather than code if you can't post good stuff. For one, they can learn more from a good algorithm. And, secondly, they can't turn your work to get a good grade. They have to still write it themselves.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- Problems With Xp Boot Loader (Windows NT / 2000 / XP)
- Algorithm Problems (Java)
- Problems With Loops... (C++)
- Win 2000 Pro loops, Set up being Restarted (Windows NT / 2000 / XP)
- Problems of looping in saving to a text file (C)
- Need some help with my do-while and while loops (Java)
- c++ nesting loops (C++)
- BASIC FORM problems... (PHP)
Other Threads in the C Forum
- Previous Thread: Fluid Mechanics program help
- Next Thread: problem about array
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi






