Welcome to our website

Here we Provide C, C++, Java, Oracle and More Tutorials for online searchings for Tutorials.
  • Fully Responsive

    • We Response with in 24 hours regarding any doubts in our Tutorials

C Data Types and Types of data types in C

Data types specify the type of data that a variable can store. All C compilers support Five fundamental data types, they are an integer(int), character(char), floating-point(float), double-precision floating-point(double) and void.

There are the following data types in C language.

TypesData Types
Primary Data Typeint, char, float, double
Derived Data Typearray, pointer, structure, union
Enumeration Data Typeenum
Void Data Typevoid

Following are the examples of some very commonly used data types used in C:

int: int variable is used to store an integer.
char: char stores a single character and requires a single byte of memory in almost all compilers.
float: It is used to store decimal numbers (numbers with floating-point value) with single precision.
double: It is used to store decimal numbers (numbers with floating-point value) with double precision.

Let's see the Primary data types. Its size is given according to 32-bit shown below:

Data TypesMemory SizeRange
char1 byte(8 bits)−128 to 127
signed char1 byte(8 bits)−128 to 127
unsigned char1 byte(8 bits)0 to 255
short2 byte(16 bits)−32,768 to 32,767
signed short2 byte(16 bits)−32,768 to 32,767
unsigned short2 byte(16 bits)0 to 65,535
int2 byte(16 bits)−32,768 to 32,767
signed int2 byte(16 bits)−32,768 to 32,767
unsigned int2 byte(16 bits)0 to 65,535
short int2 byte(16 bits)−32,768 to 32,767
signed short int2 byte(16 bits)−32,768 to 32,767
unsigned short int2 byte(16 bits)0 to 65,535
long int4 byte(32 bits)-2,147,483,648 to 2,147,483,647
signed long int4 byte(32 bits)-2,147,483,648 to 2,147,483,647
unsigned long int4 byte(32 bits)0 to 4,294,967,295
float4 byte(32 bits)
double8 byte(64 bits)
long double10 byte(80 bits)

C Data types Programs:
C Data types program:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
int main(int argc, char** argv) {
    printf("Character Bits:   %d\n", CHAR_BIT);
    printf("Character MAX :   %d\n", CHAR_MAX);
    printf("Character MIN :   %d\n", CHAR_MIN);
    printf("Integer MAX   :   %d\n", INT_MAX);
    printf("Integer MIN   :   %d\n", INT_MIN);
    printf("LONG MAX      :   %ld\n", (long) LONG_MAX);
    printf("LONG MIN      :   %ld\n", (long) LONG_MIN);
    printf("SCHAR_MAX     :   %d\n", SCHAR_MAX);
    printf("SCHAR_MIN     :   %d\n", SCHAR_MIN);
    printf("SHRT_MAX      :   %d\n", SHRT_MAX);
    printf("SHRT_MIN      :   %d\n", SHRT_MIN);
    printf("UCHAR_MAX     :   %d\n", UCHAR_MAX);
    printf("UINT_MAX      :   %u\n", (unsigned int) UINT_MAX);
    printf("ULONG_MAX     :   %lu\n", (unsigned long) ULONG_MAX);
    printf("USHRT_MAX     :   %d\n", (unsigned short) USHRT_MAX);
    return 0;
}
Output
Character Bits:   8                                                                                                                    
Character MAX :   127                                                                                                                  
Character MIN :   -128                                                                                                                 
Integer MAX   :   2147483647                                                                                                         
Integer MIN   :   -2147483648                                                                                                          
LONG MAX      :   9223372036854775807                                                                                    
LONG MIN      :   -9223372036854775808                                                                                    
SCHAR_MAX     :   127                                                                                                                  
SCHAR_MIN     :   -128                                                                                                                 
SHRT_MAX      :   32767                                                                                                                
SHRT_MIN      :   -32768                                                                                                               
UCHAR_MAX     :   255                                                                                                                  
UINT_MAX      :   4294967295                                                                                                       
ULONG_MAX     :   18446744073709551615                                                                                
USHRT_MAX     :   65535 
See Also C topics below:

Share:

Loops in C and Types of Loops in C

Loops in C:

In C, loops are used to execute a set of statements repeatedly until the given condition is satisfied.


flow chart diagram of loops



In loops sequence of statements to be executed inside the curly braces (“{}”) is known as the loop body. Every execution of the loop body condition is checked and if the condition is true loop body executes again. When condition checked to be False then loop body will not to be executed and come out of the loop and execute the remaining part of the program.

Types of the Loops in C language: 

There are three types of loops in C language. They are:
1) while loop.
2) do-while loop.
3) for loop.

Read: C For loop

While loop: While is a conditional control statement and it repeats a statement (or) block while its controlling is True. 

Syntax of While loop:


While Loop syntax:

while(condition)
{
  //body of the loop (statements)//

}
Flow chart diagram of C while loop

Explanation of the above diagram: In the while loop, the first condition is checked. If the condition is True, the code inside the body (means inside the parenthesis) will be executed. Again the loop executes until the condition becomes False when the condition becomes false exists from while loop.

Example of while program:

C While loop program:
#include<stdio.h>
 void main()
 {
  int i = 1;
    while( i < 5)
    {
     printf("i = %d\n",i);
     i++;
    }
 }


Output:
i = 1
i = 2
i = 3
i = 4
Explanation:
1) The first variable of type integer is declared and initialized to “1”.
2) While the loop condition is checked ( 1 < 5) condition is true. So the value of “i” is printed.
3) Then the value is incremented (i++) it becomes i = 2. If we did not use any increment (or) decrement operator then while loop will be executed continuously with a value i = 1. So we used the increment operator to satisfy the condition. 
4) The cycle continues until “i” becomes “5”. When “i” becomes “5” condition becomes fails. Control jumps out of the while loop.

Do-while: The do-while loop first executes the body of the loop and then the condition statement executes. If the expression is true, the loop repeat or else the loop terminates. There is a semicolon at the end of while() in do.

Syntax of Do - while loop:

C Do- While loop Syntax:
do
{
  //body of the loop//
}
while(condition);


Example of Do-while program:

C Do- While loop program:
#include<stdio.h>
 void main()
 { 
  int i = 1;
    do
    {
     printf("i = %d\n",i);
     i++;
    }
   while( i < 5);
 }
Output:
i = 1
i = 2
i = 3
i = 4
Share:

Switch Statement in C with Programs and Examples

Switch statement in C: If several options are available then it isn’t recommended to take nested if-else we should go for switch statement so that readability of the code will be improved. “Switch” is a keyword, by using which we can create a selection statement with multiple choices. Multiple choices can be constructed by using a “Case” keyword.

Syntax:

Switch Syntax:
Switch(expression)
{
 case exp1:
 statements;
 break;
 case exp2:
 statements;
 break;
 …………….
 …………….
 …………….
 case expression:
 statements;
 break;
 default:
 statements;
}
Explanation: In the above syntax, switch, case, break are keywords. Expr1, expr2 is known as “case labels”. Statements inside case expression need not be closed in braces. The break statement causes an exit from the switch statement.

The following rules apply to a switch statement:

1) The expression used in a switch statement must have an integral or enumerated type.
2) You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon.
3) The constant-expression for a case must be the same data type as the variable in the switch, and it must be a constant or a literal.
4) When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached.
5) When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement.
6) Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases until a break is reached.
7) A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.

Switch statement in C Program 1 :

C Switch program Example:
#include<stdio.h>
void main()
{
 int number;
printf("Enter a number");
 scanf("%d",&number);
 switch(number)
 {
  case 1:
  printf("Welcome to TutorialWeb.org");
  break;
  case 2:
  printf("I am Java programmer");
  break;
  case 3:
  printf("Java programming in TutorialWeb.org");
  break;
  default:
  printf("Switch Program Example");
  break;
 }
}
Output:
Enter a number
1
Welcome to TutorialWeb.org

Explanation:

1) The integer value “1” is assigned to a number variable.
2) After switch case decides then 1st case block of code gets executed.
3) Switch case executes code from top to bottom. It will validate case number with the variable number.
4) If no match is found then it will jump to the next case. It checks until found if case is not found, then the default will be executed.

Switch statement in C Program 2 :

C Switch program Example:
#include<stdio.h>
void main()
{
 int number;
printf("Enter a number");
 scanf("%d",&number);
 switch(number)
 {
  case 1:
  printf("January");
  break;
  case 2:
  printf("February");
  break;
  case 3:
  printf("March");
  break;
  case 4:
  printf("April");
  break;
  case 5:
  printf("May");
  break;
  case 6:
  printf("June");
  break;
  case 7:
  printf("July");
  break;
  case 8:
  printf("August");
  break;
  case 9:
 printf("September");
  break;
  case 10:
  printf("October");
  break;
  case 11:
 printf("November");
  break;
  case 12:
  printf("December");
  break;
  default:
  printf("Enter number between 1 to 12");
  break;
 }
}
Output:
Enter a number
7
July
Read Also C Loops:


·     C if Else Statement
·     C For loop
Share:

Gmail Login - Gmail Sign In in Gmail Account

Gmail login and reset Gmail login password:



This article is about the Gmail login and how to change the Gmail password and steps to recover the Gmail account. In order to login to Gmail, you must Signup Gmail First.

Gmail login (or) login into Gmail Mail Account

After creating your Gmail account, type gmail.com in your browser, you can log in from your PC or Mobile gadgets or Tablet. Check the inbox for opening the mail. Below shown Gmail login steps:


  1. Type Gmail.com  on your PC Browser / Mobile / tablet or type google.com on your browser google website is opened now click on "sign-in" is at the right corner of Google home page (or) Visit here: SIGN IN TO GMAIL
    Gmaillogin
  2. Enter your Gmail Account email or a phone number and after that enter the password.
    Gmail login
  3. Now after entering your Email now click on next then the password will be asked to type your password after entering your password you successfully login into Gmail.
    Gmaillogin

Change or reset your Gmail login Password

You can change the password whenever for security reasons or in the case in the event that you overlooked the password.
  1. First login into Gmail Account.
  2. Now click on settings and where you have an option "Accounts and Import" click on that.
  3. Now Change the password option is Shown where you need to change the password.
  4. Enter the new Password, and click on Change Password afterward, you have to sign in again with the new Password any doubts see the image below.
Gmail Account Password Change


Gmail Login (or) Gmail Sign in Forgot Password:



  1. In the browser, you have to open your google record and sign in.
  2. You can see "Sign-in and security," presently you can choose Signing into Google.
  3. Pick your new Password and afterward, you have to sign in again with the new Password.
  4. Enter the new Password, and click on Change Password.
Share:

Our Services

Search This Blog

  • ()
Powered by Blogger.

C Data Types and Types of data types in C

Data types specify the type of data that a variable can store. All C compilers support Five fundamental data types, they are an integer(int...