Thread: problem with running simpel beginner aritmetic program

  1. #1
    Registered User
    Join Date
    Apr 2016
    Posts
    3

    problem with running simpel beginner aritmetic program

    Hi guys,

    I was wondering if anyone could help me out. I just started with this book c programming for the absolute beginner and i just created a simpel arithmetic program as one of the excersizes in the book. The main code executes fine only the last print statement which sums up the results of the formula does not.
    Code:
    #include <stdio.h>int main()
    //This is a simpel c arithmetic program//
    {
    int iNum1 = 0;
    int iNum2 = 0;
    int iNum3 = 0;
    int iNum4 = 0;
    int iResult = (Inum1 - Inum2) * (Inum3-Inum4);
    printf("\nadd a number please                ");
    scanf("%d" , &iNum1);
    printf("\nEnter another number please        ");
    scanf("%d" , &iNum2);
    printf("\nDon't get ........ed, but another one  ");
    scanf("%d" , &iNum3);
    printf("\nand the last one                   ");
    scanf("%d\n" , &iNum4);
    printf("the formularesult is%d" , iResult);
    return 0;
    
    
    }

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Variables do not "remember" equations like that - instead, the calculation is performed with the current value of the other variables. Therefore, you need to perform the calculation after you've received the values for those other variables.

  3. #3
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    C is case sensitive.
    'INum1' is not the same as 'iNum1'.
    Other have classes, we are class

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-21-2011, 02:43 AM
  2. Replies: 5
    Last Post: 03-21-2011, 02:17 AM
  3. Keep running program and 'int' problem
    By willrs2 in forum C++ Programming
    Replies: 21
    Last Post: 02-10-2008, 11:22 AM
  4. Problem running program
    By JOCAAN in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2007, 04:09 PM
  5. Running Program Problem
    By warfang in forum C++ Programming
    Replies: 10
    Last Post: 03-28-2007, 02:02 PM

Tags for this Thread