2 easy C programs

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
You're going to bomb the midterm and final if you don't learn how to solve the problems yourself.


(Edited to remove implication that this will result in you working at McDs)
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Time frame.

What is the reason that you can not do two easy programs yourself?
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Buwahaha I shall do them with only prinft statements :evil:!

Dinner on Jefa tonight :evil:!!
 

jefa

Member
Feb 10, 2007
121
0
0
cause i dont know C..

program example: enter the age of 2 people and output the average..

i just need them today
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: jefa
cause i dont know C..

program example: enter the age of 2 people and output the average..

i just need them today
If you do not know C then why the need for the programs?
If a class assignment then it will not help you for others to do your work. You will not learn what is needed for the next step.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Originally posted by: jefa
cause i dont know C..

program example: enter the age of 2 people and output the average..

i just need them today

:confused:...

At least write the pseudo code and I'm sure people wouldn't mind helping at least a bit then :p.

Although it's not hard to do:

int age1, age2;
printf("Enter Age 1: ");
scanf("%d", &age1);
printf("Enter Age 2: ");
scanf("%d", &age2);
printf("The average is %d.", age1/age2);

:p
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Almost all C++ developers also know how to write C code, it's not an either-or choice.

How would you write the programs in C++? What parts of the C library have you stumped?
 

ngvepforever2

Golden Member
Oct 19, 2003
1,269
0
0
Originally posted by: Aikouka
Originally posted by: jefa
cause i dont know C..

program example: enter the age of 2 people and output the average..

i just need them today

:confused:...

At least write the pseudo code and I'm sure people wouldn't mind helping at least a bit then :p.

Although it's not hard to do:

int age1, age2;
printf("Enter Age 1: ");
scanf("%d", &age1);
printf("Enter Age 2: ");
scanf("%d", &age2);
printf("The average is %d.", (age1+age2)/2);

:p

fixed

ng
 

ngvepforever2

Golden Member
Oct 19, 2003
1,269
0
0
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng
 

jefa

Member
Feb 10, 2007
121
0
0
Originally posted by: ngvepforever2
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng

sigh newbies..

 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Originally posted by: ngvepforever2
fixed

ng

Good call ;). Now you know why I didn't get my math minor :Q! (Actually because I didn't want to take Calc 3 with a foreign professor. But it's like a law that no matter how good you get, you must become worse at the simplest forms of math.)

Oh and why can't you code in C if you can code in C++... like the other guy mentioned :confused:. Only time I've ever had to code in C was when I did parallel programming with MPI, but I had no problem whipping it up (bar my math :p).
 

jefa

Member
Feb 10, 2007
121
0
0
Originally posted by: ngvepforever2
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng

sigh newbies..

:confused:

ng

i knew that face was coming..

you pose an odd question

C and C++ are different languages

learning one will not allow you to write programs in both
 

jman19

Lifer
Nov 3, 2000
11,225
664
126
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng

sigh newbies..

:confused:

ng

i knew that face was coming..

you pose an odd question

C and C++ are different languages

learning one will not allow you to write programs in both

LOL you know C++ but can't be bothered to figure out how to use scanf rather than cin? Give me a break... you shouldn't be calling anyone a newbie :laugh:
 

So

Lifer
Jul 2, 2001
25,923
17
81
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng

sigh newbies..

:confused:

ng

i knew that face was coming..

you pose an odd question

C and C++ are different languages

learning one will not allow you to write programs in both

Actually, yes, it pretty much will. I learned C++ in HS and when I had to write a program in C for college it took me, maybe a half hour, tops to figure it out...

Either:
a) you really don't know C++ at all
b) You're a really bad programmer
or
c) you're the laziest programmer ever
 

ngvepforever2

Golden Member
Oct 19, 2003
1,269
0
0
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng

sigh newbies..

:confused:

ng

i knew that face was coming..

you pose an odd question

C and C++ are different languages

learning one will not allow you to write programs in both

<---man, I (a senior CS Major ) must be a newbie. That's why I only know how to code in assembly, C,C++, Java, Lisp, not too count a bunch of scripting languages.

Learning C won't make your C++ "knowledge" go away.

ng
 

jefa

Member
Feb 10, 2007
121
0
0
Originally posted by: So
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
Originally posted by: ngvepforever2
Originally posted by: jefa
id rather retain my C++ knowledge

How can you have any knowledge of C++ and not be able to write simple C programs ?Methinks you don't have any knowledge of C++ or C.

ng

sigh newbies..

:confused:

ng

i knew that face was coming..

you pose an odd question

C and C++ are different languages

learning one will not allow you to write programs in both

Actually, yes, it pretty much will. I learned C++ in HS and when I had to write a program in C for college it took me, maybe a half hour, tops to figure it out...

Either:
a) you really don't know C++ at all
b) You're a really bad programmer
or
c) you're the laziest programmer ever

the answer is C, no pun intended
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
It's not like C++ was based on C and shares so many similarities with C! :laugh:

Actually, knowing how to program in a language means nothing compared to knowing how to solve something (excluding math! I gotta keep myself out of the hole :p). It reminds me of an automata class I took in college and the difference between someone who made a 30+ state FSM compared to my 13 state FSM where both satisfied the problem... yet mine was mundo smaller (although this is more efficiency rather than problem solving... IMO efficiency is a part of solving a problem correctly).
 

ngvepforever2

Golden Member
Oct 19, 2003
1,269
0
0
Originally posted by: Aikouka
It's not like C++ was based on C and shares so many similarities with C! :laugh:

Actually, knowing how to program in a language means nothing compared to knowing how to solve something (excluding math! I gotta keep myself out of the hole :p). It reminds me of an automata class I took in college and the difference between someone who made a 30+ state FSM compared to my 13 state FSM where both satisfied the problem... yet mine was mundo smaller (although this is more efficiency rather than problem solving... IMO efficiency is a part of solving a problem correctly).

I totally agree with you on that. your FSM problem reminds me of a problem I got in my AI class in lisp in which we had to figure out how to code a problem in the minimum amount of expressions...ah ...fun class :D

ng