|
Start by indenting your code so it's readable:
#include <stdio.h>
int main()
{
int i,j;
float pound, kilogram;
printf("Pound --------- Kilos\n\n");
do
{
j=1;
do
{
printf("%5d\t",i*j);
printf("%.2f lbs = %.2f Kg\n", pound, kilogram);
j++;
} while(j<=100);
printf("\n");
i++;
} while(i<=300);
return 0;
} It makes it so much more obvious what is going on.
Then look at your code: where do you modify pound or kilogram ?
Since they do not change, it will always print the same values.
By the way, a better loop format for your application would be a for loop:
for (int i = 0; i <= 300; i++)
{
for (int j = 1; j <= 100; j++)
{
...
}
} Since you don't initialize i in your code at all, the value can be random depending on which compiler and / or compiler options you use.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
i try for loop you suggest
code:
#include <stdio.h>
# define POUNDTOKG 0.453592;
int main()
{
int i,j;
float pound, kilogram;
printf("Pound --------- Kilos\n\n");
for (int i = 0; i <= 300; i++)
{
for (int j = 1; j <= 100; j++)
{
kilogram = pound * POUNDTOKG;
}
printf("%.2f pound = %.2f Kilogram\n", pound, kilogram);
}
return 0;
}
but my expected output is like this,
======================
Pounds Kilos
======================
100.00 45.45
101.00 45.91
120.00 46.36
103.00 46.62
104.00 47.27
105.00 ........
.
.
.
300.00 136.08
but thanks
|
|
|
|
|
You never initialize the pound variable, so it will always have the same (random) value.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Can't you make simpler? Like this?
Hm, this was not supposed to be a reply to Richard, but to the OP. Sorry.
#include <stdio.h>
#define POUNDTOKG 0.453592
int main() {
printf("Pound --------- Kilos\n\n");
for (int pound = 100; pound <= 300; pound++) {
printf("%.2f pound = %.2f Kilogram\n", pound, pound * POUNDTOKG);
}
return 0;
}
modified 12-May-22 7:50am.
|
|
|
|
|
thanks, but i want like this output below, but when I run it in dev C++, pounds is not start 100 only kilos has a value I want to put 100 to 300 but how can I do that. but thanks a lot
======================
Pounds Kilos
======================
100.00 45.45
101.00 45.91
120.00 46.36
103.00 46.62
104.00 47.27
105.00 ........
|
|
|
|
|
your code is almost correct but in pound there is a no 100 to 300, how can I put it in my code, but thanks a lot
|
|
|
|
|
Well it is, kindof. The format specfier to printf is wrong.
Try this
#include <stdio.h>
#define POUNDTOKG 0.453592
int main() {
printf("Pound --------- Kilos\n\n");
for (int pound = 100; pound <= 300; pound++) {
printf("%d pound = %.2f Kilogram\n", pound, pound * POUNDTOKG);
}
return 0;
}
Pound --------- Kilos
100 pound = 45.36 Kilogram
101 pound = 45.81 Kilogram
102 pound = 46.27 Kilogram
103 pound = 46.72 Kilogram
...
298 pound = 135.17 Kilogram
299 pound = 135.62 Kilogram
300 pound = 136.08 Kilogram
...Program finished with exit code 0
Press ENTER to exit console.
|
|
|
|
|
That's great, thanks a lot for your help and finally I will pass my pre-final exam in c programming, thank you
|
|
|
|
|
it doesn't work setwindowsHookEx(), Getkeystate() and GetCursorPos().
please help me.
modified 12-May-22 0:51am.
|
|
|
|
|
Windows service applications do not have consoles so have no access to input or output devices.
|
|
|
|
|
Windows services don't run in the context of a user's desktop. At any point whilst the service is running, there could be zero, one, or many users logged in to the computer, each with their own desktop.
You need to use a different solution. For example, you can use the Windows Task Scheduler to start an application when any user logs in. That application will have access to the user's desktop.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I got the conflicting types error when I built the code, while, i searched the workspace, i only found one tyepdef,
Shrink ▲ Copy Code
typedef unsigned int uint32_t;
in Eclipse, search:typedef*uint32_t
i can't find where there is another typedef * uint32_t.
Please help to give some ideas.
|
|
|
|
|
focusdoit wrote: Please help to give some ideas. Show the code that has the problem, and the exact error message(s).
|
|
|
|
|
focusdoit wrote: Please help to give some ideas. The error message implies that you are calling a function that expected a uint32_t so check the function signature of every function you are calling.
I don't understand why nearly everyone that posts a question omits pertinent information. It would really help if you posted relevant code and error messages.
|
|
|
|
|
Thanks, it's a big project,
i found the issue,
new 1 (33 hits)
XXX_Global.h: error: conflicting types for 'uint32_t'
Line 17: typedef unsigned int uint32_t;
gcc-6.3-arm32-eabi\arm-none-eabi\include\sys\_stdint.h:48:20: note: previous declaration of 'uint32_t' was here
Line 24: typedef __uint32_t uint32_t ;
there are 2 tyepdef uint32_t
|
|
|
|
|
focusdoit wrote: i found the issue I'm happy to see you made progress. It's unusual to ask this type of basic question, you should change the variable type on those function calls to uint32_t and recompile.
It would be great if you revealed the source code. You are forcing anyone that assists you to speculate.
|
|
|
|
|
Then remove the one from XXX_Global.h.
|
|
|
|
|
Hi
I have the following collection class (referencing a struct) which is causing the complier error listed below
I ended writing my own link list becuase I couldnt resolve the issue however I am hoping that by posting this someone can maybe explain it to me
so here is the code
listed below is the complier error for some reason the complier doesnt like a Clist template in a struct
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\include\afxtempl.h(954,17): error C2280: 'CStorge::buildcombo::tcbholder &CStorge::buildcombo::tcbholder::operator =(const CStorge::buildcombo::tcbholder &)': attempting to reference a deleted function
struct stdecs
{
struct vsmdesc stordesc;
char* tcb;
struct blkdesc *ablkdescx;
struct blkdesc *fblkdescx;
struct stdecs* nextdecs;
};
struct tcbholder
{
char* tcb;
char programname[8];
struct stdecs *storageptr;
CList<stdecs, stdecs> stptr;
};
|
|
|
|
|
CList features a deleted copy contructor.
Microsoft folks think it is not useful to pass collections by value.
You could use std::list instead (I believe Microsoft folks themselves recommend std::list over CList ).
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Still get error with list me thinks it has to do that I declared stdecs just as a type without actually allocating storage i.e struct stdecs storagediscriptor; when I have the template outside of a struct it compiles thanks
|
|
|
|
|
This works for me:
#include <iostream>
#include <list>
using namespace std;
struct Foo
{
list <int> foolist;
};
int main()
{
Foo f1;
f1.foolist.push_back(5);
f1.foolist.push_back(7);
Foo f2 = f1;
for (auto i: f2.foolist)
cout << i << " ";
cout << "\n";
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Get clean build seems to do more than clist thanks
|
|
|
|
|
I cannot create MyListBox derived from CFormView. The docs say I can put the Create call in the MyListBox ctor.
I get these errors:
// dialog template must exist and be invisible with WS_CHILD set
// invalid dialog template name
I don't want to create a resource dialog template, however, like an IDD_... because my listbox is just a PLACE_HOLDER control in a resource control.
How do I get the object created without a dialog resource IDD?
|
|
|
|