Thread: What is int in , int firstnumber , secondnumber etc ?

  1. #1
    Registered User
    Join Date
    Oct 2015
    Posts
    39

    What is int in , int firstnumber , secondnumber etc ?

    What is the exact meaning of int here ?
    Initialize array ? name ?

    What is int in ,  int firstnumber , secondnumber etc ?-enter_2_numbers_to_add_c_assembly-jpg

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Introduction to C - Cprogramming.com

    int is short for integer

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Oct 2015
    Posts
    39
    Is it ok to say it like this for the sake of understanding ,

    Int line called firstnumber , secondnumber, sumoftwonumbers ?

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    No, to put that line in words:
    "Declare three variables of type int, with names firstNumber, secondNumber and sumOfTwoNumbers"
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Oct 2015
    Posts
    39
    OK , i think its easier for me to see it like this .

    Initialize Integer line called firstnumber , secondnumber, sumoftwonumbers

    Thanks

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    This is a declaration.
    int a;

    This is an initialization.
    int a = 0;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    May 2016
    Posts
    104
    Quote Originally Posted by Salem View Post
    This is a declaration.
    int a;

    This is an initialization.
    int a = 0;
    Totally out of topic but this brings out a question I have about a silly, in my eyes, rule they have at my school: not to initialize a variable during declaration, e.g int i = 0.
    Is there any particular reason why this could be considered a wise practice or is it just trolling on their part to make us waste lines -there's a 25 line limit per function...

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > not to initialize a variable during declaration, e.g int i = 0.
    You're right, your school is bone-head stupid not to allow initialisation of variables.

    The world is knee deep in problems caused by uninitialised variables.
    CVE -Search uninitialized

    Back in the mists of time, when compilers were dumb and computers were slow, initialisation cost something.

    But modern compilers will optimise out initialisations if you subsequently assign another value without using the first value.
    Plus the compilers (and tools like Coverity and Klocwork) are very good at finding 'use before initialisation' issues.

    > there's a 25 line limit per function...
    At least they're getting something right.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Oct 2015
    Posts
    39
    Quote Originally Posted by Salem View Post
    This is a declaration.
    int a;

    This is an initialization.
    int a = 0;
    Thanks

Popular pages Recent additions subscribe to a feed

Tags for this Thread