Wednesday, March 13, 2013

Programming in C-Operators And Expression

Posted by at 3:58 AM

What is operators?

An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C language program to operate on data and variables.If you want to be a C programmer your conception on Operators should be must.

C operatator variable output
         

C has a rich set of operators which can be classified as -

1  Arithmetic operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increments and Decrement Operators
6. Conditional Operators
7. Bitwise Operators


What is arithmetic operators?

 C provides all the basic arithmetic Operators. This operators + , - , * , % and / .
                         +   For performing Addition
                         -   For performing Subtraction
                         /   For performing Division
                        *   For performing Multiplication
                        %   Modulo for finding remainder in division operation 


          
#include <stdio.h>
main()

   int a;
   int b;
   int sum;
   a = 50;
   b = 60;
   sum = a + b;
   printf ("sum is : %d",sum) ;


It can be written int a,b,sum; instead of
#include <stdio.h>
main()

   int a;
   int b;
   int sum;

This print statement - printf ("sum is : %d",sum) ; contains two argument.This first argument "%d" tells the compiler that the value of the second argument sum should be printed as a decimal integer.
     Note : If you write this  printf ("sum is : %d\n",sum) ; actually \n its mean newline character.

Look this program output :  

C programming output
Output
 
 Examples of use of arithmetic operators are: 
                                          a -b                    a + b
                                          a * b                   a / b 
                                          a % b                -a * b

a + b = 110  
a – b  = -10 
a * b =3000
a / b = 0

if you write float a, b , sum ;then answer is - a + b =100.0
                                                                                     a - b = -10.0
                                                                                      a * b =3000.0
Note : when we like to use float then just  need to change  %d and have to write printf ("sum is : %f",sum);
 

What is relational operators?

 We often compare two quantities and depending on their relation ,take certain decisions.For example , we may compare the age two persons.This comparisons can be done with the help of relational operators. C supports the following relational operators -
 
Operator
Meaning
<
is less than
<=
is less than or equal to
>
is greater than
>=
is greater than or equal to
==
is equal to

Here there are some example :
                                        
(7 == 5) // evaluates to false. 
(5 > 4) // evaluates to true. 
(3 != 2) // evaluates to true. 
(6 >= 6) // evaluates to true. 
(5 < 5) // evaluates to false.
 
  1. Suppose that a=2, b=3 and c=6
  2. (a == 5) // evaluates to false since a is not equal to 5. 
  3. (a*b >= c) // evaluates to true since 
  4. (2*3 >= 6) is true. (b+4 > a*c) // evaluates to false since 
  5. (3+4 > 2*6) is false.  
  6. ((b=2) == a) // evaluates to true.

What is logical operators?

In addition to the relational operators,C has the following three logical operators
                
&&
Logical AND
||
Logical OR
!
Logical NOT
  
 The logical operators && and || and used when we want to test more than one  condition and make decision.An example is : 
                                   a > b &&  x==10
For example
#include <stdio.h>
void main()
{
    int n;
    scanf("%d",&n);
    if ((n%2)==0)
    {
        printf("Even");
    }
    else
    {
        printf("Odd");
    }
}
 
Note : here if else is if else statement.next time discuss this if else.stay with us..........>>>>>>>>>>

The logical OR is used to combine 2 expressions or the condition evaluates to true if any one of the 2 expressions is true. An example is :  
                                    a < m || a < n 

The logical not operator takes single expression and evaluates to true if the expression is false and evaluates to false if the expression is true. In other words it just reverses the value of the expression.  

What is assignment operators?

 Assignment Operators are used to assign the result of an  expression ta a variable.

example
x = a + b
Here the value of a + b is evaluated and substituted to the variable x.

In addition, C has a set of shorthand assignment operators of the form.
var oper = exp;

Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator.


x + = 1 is same as x = x + 1
The commonly used shorthand assignment operators are as follows

Shorthand assignment operators
 
Statement with simple
assignment operator
Statement with
shorthand operator
a = a + 1
a += 1
a = a – 1
a -= 1
a = a * (n+1)
a *= (n+1)
a = a / (n+1)
a /= (n+1)
a = a % b
a %= b

What are increment and decrement Operators?

The increment and decrement operators are one of the unary operators which are very useful in C language. They are extensively used in for and while loops. The syntax of the operators is given below
                                     1. ++ variable  name  (prefix)

Here ++ is used before variable name means 1 add before  
                                      
                                      2. variable name++ (post fix)


after ++ mean 1 add after run program                                       
                                      3. – –variable name(prefix)                                       
                                      4. variable name– –(post fix)

Example 1Example 2
B=3;
A=++B;
// A contains 4, B contains 4
B=3;
A=B++;
// A contains 3, B contains 4






 What is Conditional operators?

The conditional operator consists of 2 symbols the question mark (?) and the colon (:)
The syntax for a ternary operator is as follows

                                              exp1 ? exp2 : exp3 

The ternary operator works as follows

exp1 is evaluated first. If the expression is true then exp2 is evaluated & its value becomes the value of the expression. If exp1 is false, exp3 is evaluated and its value becomes the value of the expression. Note that only one of the expression is evaluated.

For example

a = 10;
b = 15;
x = (a > b) ? a : b

Here x will be assigned to the value of b. The condition follows that the expression is false therefore b is assigned to x.

 #include<stdio.h>
main( )
{
int a , b , larger;
printf ("Input 2 integers : ");
scanf("%d %d",&a , &b);
larger = a > b ? a : b;
printf("The largest of two numbers is %d \n", larger);
}

if you type 2 integers  10  15   then output -

 

Bitwise Operators :
C has a distinction of supporting special operators known as bitwise operators for manipulation data at bit level.

Operator
Meaning
&
Bitwise AND
|
Bitwise OR
^
Bitwise Exclusive
<< 
Shift left
>>
Shift right

Feel free comment me in the comment box.

Monday, March 11, 2013

Programming in C-Variable and Data types

Posted by at 5:06 PM
I hope all of you are able to install Codeblock .I like to use key-board short-cut keys and for creating a new file press  ctrl+shift+N

# Now write-
                        #include <stdio.h>
                                 int main ()
                             {
                                printf("Hello World");
                                return 0;

                             }

 #include<stdio.h>  -It is the header file.Every programmed has it's header file .Here .h is the extension of header.You should identify what you want to do and declare it with the header file so that the machine can get the direction of variable.  

What Exactly is a Variable Declaration ?. 

                                    #include <stdio.h>
                                     int main()
                               {
                                    int a;
                                    int b;
                                    int sum;
                                    a = 50;
                                    b = 60;
                                    sum = a + b;
                                    printf("Sum is %d", sum);
                                    return 0;
                                }

Here a, b, sum, are variable.

  In this example- int a;

           this statement is a combination of declaration of integer( int ) a and assign its value to it,so it is a definition statement.
A variable is the name for a place in the computer's memory where you store some data. A variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer.


c programming-mywebtune
                                   
                                   Data Types : When we use a variable in a program then we have to mention the type of data.

C has the following basic built-in data types:
  • int
  • float
  • double
  • char

    int - data type

    int is used to define integer numbers.
        {
            int a;
            a = 50;
        }
    

    float - data type

    float is used to define floating point numbers.
        {
            float a;
            a = 50.6;
        }
    

    double - data type

    double is used to define BIG floating point numbers. It reserves twice the storage for the number. On PCs this is likely to be 8 bytes.
        {
            double A;
            A = 2500000;
        }
    

    char - data type

    char defines characters.
        {
            char Letter;
            Letter = 'x';
        } 
    Feel any problem,then comment me.
    see you again.....



          

Sunday, March 10, 2013

Programming in C

Posted by at 9:32 PM

What is Programming: 

Programming is the process by which instructions can be converted into machine language.It is usually used in computer.Basically these instructions are written language which we call source code .
There are various types of programming languages like C ,C++,Java,Python etc.I would like to discuss about C programming so that We can easily learn C programming.

Very basic on C and C++ Programming:

Today the C & C++ programming language are still quite popular.In fact, many modern programming languages, such as Java, C++ programming language, were based on various features of the C language.C language is a base to learn different programming language.If you want to learn C++ or JAVA, without the knowledge of C it becomes very difficult to learn these programming languages.
I hope all are understand importance of C.Okey, Let's start our very first programming language in C.


c programming
 Getting set up - finding a C compiler :   The very first thing you need to do, before starting your journey is to make sure that you have a compiler.

What is a compiler:

 A compiler turns the program that you write into an executable that your computer can actually understand and run just it. If you're starting out on your own, your best bet is to use Code::Blocks with MinGW and if you're on Mac OS X, you can use XCode.
I am using code-block and will start our first programming. 




JavaScript-Your First javaScript code

Posted by at 6:15 PM

Write your first javaScript code:

I think you have now the basic idea of javaScript and why this language has been created.For practice you need a text editor like notepad++,conText,Sublime text etc.
# Go to your text editor and make a document save as test.html.
# Here we will write the javaScript code.

N.B.JavaScript codes can be written in any position you need within HTML documents.

Now, write your first code.
#After the body tag write
 
         <script type="text/javascript"></script>

You will write your javaScript code between this tag.
# Now let's having your first code:
          <script type="text/javascript">
                 document.write("Welcome to Mywebtune");
          </script>  
N.B:There must be endwith ";" symbol and the document will be within("document");

# If you want to make alert box then write 
         <script type="text/javascript">
                 alert("Welcome to Mywebtune!");
          </script>  

You will get a output with alert box when visiting your site.See the above codes



javascript-mywebtune
   
                              first-javascript
        
 
                
 

 

Introduction to JavaScript.

Posted by at 1:23 PM
I have decided to make a compete JavaScript Tutorial.I will discuss about all of the components on JavaScript from beginner to advance level.
If you want to be a professional web developer,you must understand and the proper implementation of  JavaScipt .After completing xhtml and css,you will learn to create a static website.You need to acquire the power of using JavaScript libraries to make this static site into dynamic. So, let's get starting.
javascript-mywebtune


What is JavaScript:

JavaScript is a very popular interpreted computer programming language now a days.It is used for creating dynamic website.Specially for creating your site more professional and beautiful.It is abbreviated as Js.

Why we use JavaScript:

# We can JavaScript in billion of web pages to add dynamically or functionality.
# JavaScript is used for making validate forms 
# To create effects on webpage
#also used for communicate with the server and much more.
This is the very beginner level and I will discuss on JavaScript step by step.
If feel any question then comment from the comment box,I will try to solve your problem.
Thanks for being with me.

How to remove default navigation menu from blogger

Posted by at 11:53 AM
Blogger is a great platform for blogging and it is totally free.It is the one and only platform to develop your web development skill here.I am sure about that you are able to make a simple blogspot site and there are some awesome blogspot templates.
But you are not liking the default navigation menu.So, here is the tips on how to remove the default navigation menu from it within a short moment following the easiest way.
Here  is the default navigation menu like this..
default blogspot nav-bar
 1st-step:
#Go to your blogger dashboard
#Then go to Design > Template Designer > Advanced > Add CSS
2nd-step:
Add this code here
     #navbar-iframe {display: none !important;}
Now click on apply template.
This is the updated information on removing the default nav-bar from the blogspot template.
 

Thursday, February 28, 2013

Sublime text3 editor is finally released

Posted by at 3:38 PM

What is Sublime text3

Sublime text3 editor is one of the best editor from sublime text authority for web developer which features IDE.
Recently Sublime text authority has released the full version of sublime text3 with some additional facilities.It offers more and more polished experiences.
Some of the notable ones are:

Sublime indexing:

Now sublime text is enable to scan the files in your project,
enable the power of creating an index of which files contain which symbols
 backs the new features , Goto Definition and Goto Symbol in Project.

sublime text3
             

Facilities of pane management:

  New option for View/Groups, View/Focus Group and View/Move file to Group.

Very easy to work with different panes and and user can easily create and destroy new panes.

Best speedy editor:

 It is the best speedy editor i have ever seen. vesrsion 3 is virtually immediate and
The plugins does not have the opportunity to bring this down.
If you want to get more information you can visit sublime blog.

 

Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks

Members

©2013 My WebTune is powered by Blogger