C program print integer

#C program print integer

C programming code-

#include <stdio.h>                //header file

int main()
{
   int a;                    //variable declaration

  printf("Enter an integer\n");        //print double cote statement
  scanf("%d", &a);            //read the integer value enter by user

  printf("Integer that you have entered is %d\n", a);//print statement as well        value of“a”

  return 0;

}


Data Type integer
In the C programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.

Integers don’t have any decimal points and they can be signed or unsigned. We have three types of integer data types in the C languages including Short int, int, and Long int. The range of signed short int is between -128 to +127 and having 8 bit size (integer values occupy 8 to 32 bits of the memory), for unsigned short int it is between 0 to 255 again with 8 bit size. The signed long int has 32 bit size and its range is from -2,147,483,648 to +2,147,483,647.



#C program to store integer in a string

#include <stdio.h>

int main ()
{
  char n[1000];                        //  variable of size 1000

  printf("Input an integer\n");    //get input integer number of size of variable n[1000]

  scanf("%s", n);            //read i/p number and store into variable n

  printf("%s", n);            //print the variable n

  return 0;               
}

Output of program:

Input an integer
123456789
123456789

Comments

Popular posts from this blog

C Program to Display the ATM Transaction

Fortran

Java programming language