Advertisement

Basic C program what am I doing wrong?

Started by April 27, 2015 01:24 PM
12 comments, last by Shubhz_Dingar 9 years, 8 months ago

Prepare to have your hopes dashed Dave Hunt... I doubt he's working on the next gen interest calculator game.

- Eck

Is it sad that actually sounds like a better game than some of the junk out there now?

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

lol now I am in 2 dimensional Array.
I am learning C and then will C++ and then some graphic libraries and then Unreal engine 4. :P
I am a long long way off though :D

Advertisement
That seems like a fine goal, but just checking if you know that you don't strictly need to learn C before C++?

Despite it's origin C++ is a completely different language to C, and the correct idiomatic usage of each language is very different; code that is normal and correct C will probably be considered bad C++, and code that is normal and correct C++ may not even compile as C.


If you want to learn both languages that's great -- knowing C can be beneficial in its own merits -- but if you're just doing it because you thought you needed to to properly learn C++ you may as well save yourself the time and effort by just starting with C++.

- Jason Astle-Adams


#include<stdio.h>
#include<conio.h>
main(){
   int p,v,n;
   double r;
  for(p=1000;p<=10000;p=p+1000)
      for(r=0.10;r<=0.20;r=r+0.01)
         for(n=1;n<=10;n++){
            v=p*1+r;
            p=v;
            printf("Value of money %d",v);
            printf("Principal %d",p);
            printf("time %d",n);
            printf("Rates %d",r);
         }
   getch();
   return 0;
}
It is to print the table that would show value of v for various combination of the following values of p,r,n.

1. %d shouldn't be there for r.

2. create a curly brace after every loop as by not creating it you are making the first for loop unreachable.

This topic is closed to new replies.

Advertisement