Tuesday, March 31, 2020

C program to check character is alphabet or not


C program to check character is alphabet or not


#include 
int main()
{
    char c; // character variables
    printf("Enter a character: "); // user enter character value
    scanf("%c", &c); // stpre value
    
        // check character or not
    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) 
        printf("%c is an alphabet.", c);
    else
        printf("%c is not an alphabet.", c);
        
    return 0;
}

Output

Enter character *
* is not character

How program works ?

  • In this program, 'a'  is used instead of  97 and 'z' is instead of  122.
  • Similarly, "A" is used instead of 65 and "Z" is instead of 90

Happy coding

C Program check number is positive or negative using if else

C Program check number is positive or negative using if else 

#include 
int main()
{
    double num; // constant number
    printf("Enter a number: "); // enter user 
    scanf("%lf", &num); // storing constant value
    if (num <= 0.0) // check number is greater or not
 {
        if (num == 0.0)
            printf("You entered 0.");
        else
            printf("You entered a negative number.");
    } else
        printf("You entered a positive number.");
    return 0;
}

Output

Enter a number : 32
You entered Positive number

Happy Coding

C Program to Swap two number without using temporary variable

C program to Swap two Numbers Without Using Temporary Variable

#include 
int main()
{
    double a, b; // initialization constant variables
    printf("Enter a: "); // user enter number
    scanf("%lf", &a); // storing value of user number
    printf("Enter b: "); // user enter number
    scanf("%lf", &b); // storing value of user number

    // Swapping process
    a = a - b;
    b = a + b;
    a = b - a;

    printf("After swapping, a = %.2lf\n", a); //swaping 
    printf("After swapping, b = %.2lf", b); //swaping
    return 0;
}

Output

Enter a: 5.25
Enter b: -6.5
After swapping, a = -6.5
After swapping, b = 5.25

Happy Coding 

C program to swap two numbers

C program to swap two numbers

#include
int main()
{
      double first, second, temp; // initialization of constant value 
      printf("Enter first number: "); // user input value
      scanf("%lf", &first); // Storing value
      printf("Enter second number: "); // user input value
      scanf("%lf", &second); // Storing value

      // Value of first is assigned to temp
      temp = first;

      // Value of second is assigned to first
      first = second;

      // Value of temp (initial value of first) is assigned to second
      second = temp;

      printf("\nAfter swapping, firstNumber = %.2lf\n", first); // Final display result
      printf("After swapping, secondNumber = %.2lf", second); // Final display result
      return 0;
}

Output 

Enter first number: 4.6
Enter second number: 4.5

After swapping, firstNumber = 4.5
After swapping, secondNumber = 4.6
How program works ?

  • In this program, the temp variable is assigned the value of the  first  variable. 
  • Then, the value of the first variable is assigned to the  second variable.
  • Finally, temp  (Which hold the initial value of first ) is assigned to second.This completes the swap process.
Happy coding

Monday, March 30, 2020

c program to Find ASCII Value of a Character

C Program to Find ASCII Value of a Character

In C programing, a Character variables holds ASCII value (an integer number between 0 to 127)
rather than that character itself. That value is known as it's ASCII value.
For example, the ASCII value of  'A' is 65.
What this means that, if you assign 'A' to a character variable, 65 is stored in the variable rather than 'A' itself.
Now, how we can print ASCII value of character in C programming. 
#include 
int main()
 {  
    char c; // Character value
    printf("Enter a character: "); // user input 
    scanf("%c", &c);  // Storing value 
    
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
    
    return 0;
}

Output

Enter a character: D
ASCII value of G = 68
In this program, the user is asked to entered a character. The character is stored in variable  c.
When %d format string is used, 68( the ASCII value of  D) is displayed.
When  %c format string is used, 'D' itself displayed.

Happy coding

c program to find the size of int float double and char

C program to find the size of int, float, double and char 


#include
int main() 
{
    int intType; // integer value
    float floatType; // Constant value
    double doubleType; // double Constant value
    char charType; // Character value

    // sizeof evaluates the size of a variable
    printf("Size of int: %ld bytes\n", sizeof(intType));
    printf("Size of float: %ld bytes\n", sizeof(floatType));
    printf("Size of double: %ld bytes\n", sizeof(doubleType));
    printf("Size of char: %ld byte\n", sizeof(charType));
    
    return 0;
}

Output 

Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Size of char: 1 byte
In this program, 4 variables Int, float, double  and char are declared.
Then, the size of each variables is computing using the sizeof operator. 

Happy coding

c program to multiplay two numbers

C Program to Multiply two number


#include 
int main()
{
    double a, b, product; // Initialization
    printf("Enter two numbers: "); //ask to user enter two numbers
    scanf("%lf %lf", &a, &b);  // storing values 
 
    // Calculating product
    product = a * b;

    // Result up to 2 decimal point is displayed using %.2lf
    printf("Product = %.2lf", product);
    
    return 0;
}

Output

Enter two numbers: 3.4
5.10
Product = 8.5

How program is work ?

  • In this program, the user is asked to entered two number which is stored in the variables a and b. 
  • Then, the product of a and b is evaluated and the result is stored in product.
product = a * b ;
  • Finally, Product is displayed on the screen using printf()
printf("Product = %.2lf", product);
Happy Coding

c program to add two integer numbers

C program to add  two integer number

#include 
int main()
{    

    int number1, number2, sum;
    
    printf("Enter two integers: "); // Value from user
    scanf("%d %d", &number1, &number2); // Storing value

    // calculating sum
    sum = number1 + number2;      
    
    printf("%d + %d = %d", number1, number2, sum); // Final result 
    return 0;
}

Output

Enter two integers: 12
11
12 + 11 = 23

How program works ?

  • In this program, the user asked to enter two integer values. These integer values are stored in number1 and number2
  • Then, these two integer number are adding in ' + ' operator, and result is stored in the sum variable.
Sum = number1 + number2;
  • Finally, printf()  function is used to display the sum of two integer number.
printf("%d + %d = %d", number1, number2, sum); // Final result 

c program hello world program

C Program to display " hello world "

#include 
int main()
{
   // printf() displays the string inside quotation
   
   printf("Hello, World!");
   
   return 0;
}

Output 

Hello, World!

How "hello world" program works ?

  • The #include is preprocessor command that tells the compiler to include the content of stdio.h ( Standard input and output ) file in the program.
  • The stdio.h file contains function such as scanf() and print() to takee input and display output respectively.
  • If you see the printf() function without writing #include<stdio.h>, the program will ot be compiled.
  • The execution of C program starts from the main() function.
  • printf() is a library function to send formatted output to the screen. In this program, printf() display hello world to the screen.
  • The return 0; statement is the Execution of the program. In simple terms. The program ends with this statement.  

Sunday, March 29, 2020

What is Input Output in C Language .

Input and Output (I/O)

In this you will learn to use scanf() function to take input from user and printf() function to display the result to the user.

C Output

In C programming, Printf() funcation is the main output function to display result to user. The function sends formatted output to the screen.

Example 1 : C Output 

                                                                                                                                                                                                                                                                                                                                                                                                                         


Output
C Programming

How does this program work

  • All valid C program must contain the main()  function.The codes execution begins from the start the main() function.
  • The printf() is a library function to send formatted output to the screen. The function prints the string inside the quotations.
  • To use prinf() in our program, we need to include stdio.h  header file the #include<stdio.h> statement.
  • The return 0; inside the main() function is the " Exist status " of the program.

Example 2 : C Integer Output 

  

                                                                              







Output
Number =5

We use %d specifier to print int types. Here, the %d inside the quotations will be replaced the value of testInteger.

Example 3 : C float and double Output











Output
number1 = 13.5000
number2 = 12.4000

To print float, we use %f  format specifier, similarly we use %if to print double
values.
Example 4 : C print character








Output
character = a
To print char , we use %c format specifier.

Input

In C programming, scanf is one of the commonly used function to take input from the user. The scanf() function reads formatted input from the standard input such as keyword. 

Example 5 : C integer Input/Output












Output 
Enter an integer : 4
Result 
Number = 4 
Here, we have used %d format specifier inside the scanf() function to take int from the user. When the user entered an integer, it is stored  in the testinteger variable.

Example 6 : C float and double Input/Output



















Output
Enter a number =12.54
Enter another number =34.54
num1=12.54
num2=34.54

We use %f and %if format specifier for float and double respectively.

Example 7 : C Character Input/Output













Output
Enter a character : a
You entered a

When a character entered by the user in the above program, the character itself is not stored. Instead, an integer value ASCII is stored.
And when we display that value using  %c text format, the entered character is displayed. If we use %d to display the character, its ASCII value is printed.

Example 8 : C ASCII value Input/Output















Output
When a character :g
you entered :g
ASCII value is 103

Input/Output Multiple Values












Output
Enter integer and then float :  -3
3.5
You entered -3 and -3.50000

Format Specifier for I/O

  • %d      <=====>    Interger_value
  • %f       <=====>   float_value
  • %if      <=====>   double_value
  • %c      <=====>   Character_value

Saturday, March 28, 2020

What is C Data Type structure

C Data Type

In this you will learn basic data types such as int, float, char etc in C programming.
In C programming, data types are declaration of variables. This determines the type and size of data association with variables. 
For example :
Here, myVar, is a variable of int (integer) type.The size of int is 4 bytes.

Basic Data_types

Here's a table of containing commonly used types inn C programming for quick access.



Int

Integer are whole numbers that can have both zero, positive and negative but no decimal values.
For example :
we can use int for declaration an integers variables .
int a;

Here,  a is a variable of type integers.
You can declare multiple variables at once in C programming. 
For example :
int a , age;

The size of int is usually 4 bytes ( 32 bits ). And it can take 2 pow32.

Float and double

float and double are used to hold real numbers.
float salary;
double price;
In C floating-points numbers can also be represent in exponentional.
For example :
float normalization_factor = 22.442e2

What's the difference between float and double?

The size of float ( single precision float data type) is 4 bytes. And double ( double float precision data type ) is 8 bytes.                                                                                                                                        

Char             

Keyword Char is used for declaring character types variables.
For example 
char test = 'h' ;
The size of the character variable  is 1 byte.                                                                                              

Void 

void is an incomplete type. It means "nothing" or " no type". You can think  of void as absent.
For example :
If a function is not returning anything, its return type should be void.
Note that you cannot create variable void type.

Short Long

If You need to used a large number,you can use a specifier long. Here's Show below 
long a ;
long long b ; 
long double c ;

Here, a and b can store integer values. And C can store floating point number.
If you are sure, only a small integer  ( -32 , 767 ,+32 , -767 range) will be used, you can use short.
short b ;

You can always check the size of variable using the size of() operator.


Signed and unsigned

In C sign and unsigned  are the modifiers. You can alter the data Storage of data type by using them.
For example :
unsigned int  x ;
int  y ;

Here, the variable can hold only zero and positive values because we have used unsigned modifiers.
 Considering the size of  int is 4 bytes, variable y can hold values from -2pow31 to -2pow31 -1, Where variable x can hold values from 0 to 2pow32 -1 

Other data_types in C programming are :
  • bool type
  • Enumerated type
  • complex type

Derived Datatypes 

Datatypes that are derived from fundamental datatypes are derived types.
For example :
array, pointer., function types, structures etc. 

Friday, March 27, 2020

What is Floating-point literal ?




 Floating-point literal                                                                                          A Floating-point is a numeric literal that has a fractional form or an exponent form.
For Example 
                      -2 ,  0.0000342 ,  -0.33E5 etc
Note  E-5 = 10 -5

Character   

A character literal is created by enclosing a single a single character inside quotation marks. 
For example : 'a' 'b' '3' 'D' '{' etc 

Escape Sequence

Sometimes, it is necessary to use characters that cannot be typed or has special meaning in C programming. For example : newline(enter) ,tab, question mark etc .
In order to use these characters, escape sequence are used. 

           Escape Sequence

|     \b                                 Backspace
|     \f                                  Form feed
|     \n                                 Newline
|     \r                                  Return
|     \t                                  Horizontal tab
|     \v                                 Vertical tab
|     \\                                 Backslash
|     \'                                  Single Quotation mark
|     \"                                 double Quotation mark 
|    \?                                 Question mark
|    \0                                 Null Character

For example : \n is used for newline . The backlash  \ causes escape from the normal way the characters are handled by the compiler.

Strings literals

A string literal is a sequence of character enclosed in double-quote.
For example 
"good"       \\ String constant 
" "              \\ Null string character 
"z"             \\ String constant having single character
"Earth is round \n"         \\ Print string with a newline

Constant

If you want to define a variable whose value cannot be  changed, you can use the constant keyword.
For example : const double PI =3.14;
Notice : PI  Symbolic constant; its value cannot be changed. 

Constant double PI = 3.14;   \\ Constant value 
PI = 2.4   \\ Error   

You can also define a constant using the define  preprocessor directive. 

You will learn about C Macros tutorial .

C Variables, Constants and literals


C Variables, Constants and literals 

In this you will learn about variables and rules of naming a variable. You will  learn about different literals in C programming and how to create constant.

Variables

In programming, a variable is a container ( storage data ) to hold data.
To indicate the storage area, each variable should be given a unique name ( identifier ). Variable names are just the symbolic representation of a memory location.
For example
                      int  Play_Score = 94;

Here, Play_score is a variable of  int type. Here, the variable is assigned an integer value 94.
The value of a variable can be changed, hence the name variable.

char ch = 'a';   // some code 
ch = '5';

Rules for for naming a variable 

  • A variable name only have letters ( both uppercase and lowercase), digits and underscore.
  • The first letter of variable should be an either letter or an underscore.
  • There is no rule on how long a variable name (identifier) can be. However you may run into  problems in some compilers if the variables name is longer than 31 character.
Note :    You should always give a meaningful names to variables. 
              For Example  : first_name is better variable name than first_name.

C is a strongly typed language. This means that the variable cannot be changed  once it is declared.
For example :
             int number =5;    // integer variable
             number =5.5;   // Error 
            double number;   // Error
   
Here, The type of number variable is int. You cannot assign a floating-point ( decimal ) value 5.5 to this variable. Also , you cannot redefine the data type of the variable to double. By the way, to store the decimal values in C, you need to declare its types to either double or float.

literals

literals are data used for representing fixed values, They can be used directly in the code.  For example 1, 2.3 'A' etc 

Here, 1, 2.3 and C are literals. Why ? You cannot assign different values to these terms.                      

  • Integers 

An integer is a numeric literal ( associated with numbers ) without any fractional and exponential part. There are three types of integer literal in C programming.

  • Decimal ( base 10 )                                                                                                                          
  • Octal base ( base 8 )
  • Hexadecimal ( base 16) 
For Example 
Decimal : 0, -9, 22 etc
Octal : 021, 077, 033 etc
Hexadecimal : 0x7f, 0x2a, 0x521 etc

In C programming octal starts with 0, and hexadecimal start with a 0x.   

                                                                    

Thursday, March 26, 2020

c program to display an integer value

C Program to print Integer value

#include 
int main() 
{   
    int number;
   
    printf("Enter an integer: "); //user value 
    
    // reads and stores input
    scanf("%d", &number);

    // displays user output
    printf("You entered: %d", number);
    
    return 0;
}

Output

Enter integer number = 45
You entered 45

How program works ?

  • In this program, an integer variable number is declared.
Int number;
  • Then. the user asked to enter an integer number, This number is stored in the number  variable.
printf("Enter an integer: ");
scanf("%d", &number);
  • Finally, the value stored in number is displayed on the screen using printf().
printf("You entered: %d ",number );

C Keywords and Identifier



C Keywords and Identifier 

In this tutorial, you will learn about keywords, reserved words in C programming that are part of the Programming. Also you will learn about identifiers and how to name them.

Character set

A character set is a set of alphabets, letter and some special character that are valid in C language. 

Alphabets  

Uppercase : A B C .............. X Y Z 
Lowercase : a b c   ..............  x y z 

( C Accepts both uppercase and lowercase  alphabets as variables and functions. )

Digits 

0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10  and so on.

Special Character's

Whenever you write any C program then it consists of different statements, Each C program is a set of statement and each statements is different C programming language. In programming each and every character is singe language.
    Types                                  Meanings                                                                
|                                               Tilde              |                                                                 
|       !                                Exclamation mark  |
|       #                                    Number sign     |                               
|       $                                     Dollar sign         |                                                               
|       %                                    Percentage        |                                                                 
|       ^                                        Caret               |                                                               
|       &                                    Ampersand       |                                                             
|       *                                       Asterisk             |                                                           
|       (                                 Left Parenthesis     |                                                     
|        )                               Right Parenthesis    |                                                         
|       _                                     Underscore        |
|       +                                      Plus sign            |
|       |                                      Vertical Bar         |
|        \                                     Black Slash        |
|       `                                      Apostrophe       |
|        -                                     Minus sign          |
|       =                                      Equal sign          |
|       {                                       Left brace          |
|       }                                      Right brace         | 
|       [                                      Left bracket        |
|       ]                                      Right bracket      |
|      :                                            Colon              |
|      "                                     Quotation mark    |
|      ;                                        Semi colon        |
|      <                              Open angle Bracket  |
|      >                              Close angle bracket  |
|      ?                                    Question mark      |
|      ,                                          Comma            |
|       .                                          Period              |       
|      /                                            Slash             |

White Space Characters 

Black space, Newline, Horizontal tab, Carriage, Return and form feed.



C Keywords

Keywords are predefined, reserved words are used in programming that have special meaning in the compiler. Keywords are part of syntax and they cannot be defined as an identifier.
For example
                        int money;
Here , int is a keyword that indicates money is a variable type of int ( Integer).

Keywords

auto  , double ,  int ,  struct ,  break , else , long , switch , case ,  enum , register , type define ,
char , extern , return , union , continue , for , signed , void , do , if , static , while , default ,
goto , sizeof , volatile ,  constant , float , short , unsigned.

All these keywords, their syntax, and application will be discussed in their respective topics. However, if you want a brief overview of these keywords without going further, List of all keywords in C programming.

C Identifiers 

Identities refer to name given to entities such as variables, functions, structure etc. Identifiers must be unique. They are created to give unique name to an entity to identify  its during  the execution of program. 
For Example

int money;
double account_balance;

Here, money and account_balance are identifiers.
Also remember, identifiers name must be different from keywords. You cann't be use int as identifiers because int is Keyword.

Rules for naming identifiers

  • A valid identifiers can have letters (Both Uppercase and lowercase letters), digits and underscores.
  • The first letter of an identifiers should be either letter or an underscore.
  • You cannot use keywords as identifiers.
  • There is no rule on how long identifiers can be. However, you may run into problems in some compilers if the identifiers is longer 31 Character.
You can chose any name as an identifier if you follow the above rule, however, give meaningful names to identifiers that make sense.

How to Become a Software Engineer if You Don't Have a Computer Science Degree

Technology


How to Become  a Software Engineer if You Don't Have a Computer Science Degree.

There isn't just one way to become an engineer anymore. These days you can attend a bootcamp, teach yourself, get a degree, or get an internship. I attend a bootcamp but I Still had to teach myself during it and just figure things out. 

My firs company hired me as an apprentice on a trial basis, After I Proved myself, they hired me as a full-time engineer. I'm now a  published author with one of the biggest engineering publishing companies  in the world. 

Meanwhile, my sister offered to work for free at a company for the first few weeks, just to prove she could do the work. This just goes to show that there are so many paths open to anyone willing to work hard and learn.

If you didn't get a CS degree, that's fine! There are so many other paths to becoming a software engineer. Let's look at a few of them here. 

Bootcamps


A legitimate bootcamp is a great investment in your career. When I graduated from college, I felt a little lost on what I wanted to do next.

I'd always loved coding but had never purchased it. My aunt knew that I was trying to figure out What I should do for my first real career steps, besides internships and part-time jobs in college, and sent me an email about coding bootcamps. This absolutely saved me. 

I had never even heard of a coding bootcamp before. I immediately starting doing a ton of research. It just seemed too good to be true. I read blog post from every single that had been to the bootcamp that I could find online. I read any review I could find. I started emailing students that attended the bootcamp and begging them to answer a few questions.

After I did my Research, I decided to apply to Dev  bootcamp. I was so nervous when I got in. I didn't have the money at the time so I had to take a loan from my parents. I couldn't even find a reasonably priced apartment in San Francisco, so I was Sleeping on a bunk bed with a roommate in a crowded house that had the vibe of Ron Weasley's house but without the magic.

It was the best thing I had ever done.

Fast Forward fiver year's and I'm a senior Software Engineer. I Speak at conferences all the time, Iv'e worked at big public companies such as Eventbrite and Pandora. I've been interviewed  for newspaper and television several times. I've been paid to consult at cutting edge companies, and I'm a published in the world. A coding bootcamp completely changed my life.

But it didn't work out for everyone that attend with me. I out started  out with 50-60 students in my cohort. By the time we graduated, about ten graduated with us. Some had staying behind a cohort to learn a little more. Some dropped out early, While they got a significant refund.
Otherwise decided that engineering wasn't for them partway thought the program when the financial loss was high. Other were asked o leave because they couldn't keep up.

A coding bootcamp in one of the largest pruchases you'll make in you'r life. Do your search. Many horror stories exist online of people who paid $10-20k only to find out the bootcamp was a scam or the teachers were inadequate.

A good bootcamp will start with an online phase first. where you'll learn from your home. It will teach  you the basics concepts of programming so that when you to the onsite portion of the program, you can focus on the tougher engineering with teacher around to answer your questions.

Make sure that you find a program that ask has a phase focused on the interviewing prep and that supplies you with a career team. This was one of the most beneficial parts of  my bootcamp. I got my first engineering job because the bootcamp helped me write out my linkedIn and make my profile stand out. My first company actually found me on linkedin -- I didn't even have to apply.

If you do decide to research coding bootcamp. I recommended you start with the following. Bootcamps: Hack Reactor, App Academy, and Hack bright.

Self-Learning   

If you have the time and can manage your own time well, this  option might be a great fit. It's definitely the toughest choice because you will need to keep to a schedule and stay motivated.

It's important to set goals to keep yourself on track. I recommend starting out with free resources before you commit to a more expensive paid course online. Try the free Code Camp responsive web design course to start out.

Once you've completed a few online coursed, start challenging yourself. Don't just keep following tutorials. Try to build something of your own.

Pick an idea that you're really excited about. If you're really passionate about what you're building, you'll be motivated to keep going. Do yo have any fun website ideas or command line projects you could try to build? Start small but keep increasing the complexity in your projects for you portfolio .

             
     

Recent Posts