-->

Facebook

Jasper Roberts - Blog

Saturday, February 28, 2015

Switch...case Statement in C programming language.

In C programming language, sometimes we need to check multiple conditions. At that time we can you switch...case statement.

Syntax:
switch(choice)
{
case value1:
statement-1;
break;
case value2:
statement-2;
break;
case value3:
statement-3;
break;
case value4:
statement-4;
break;
.
.
.
.
.
case value-n:
statement-n;
break;

default:
default statement;
}


Example: A C Program to add, subtract, multiply, divide two values using switch...case statement.

Thursday, February 26, 2015

Write a C Program to convert Fahrenheit temperature to Centigrade.

// C Program to convert Fahrenheit temperature to Centigrade.

#include<stdio.h>
#include<conio.h>

void main()
{
       float fah, centi;
       clrscr();

       printf("Enter the temperature in Fahrenheit:");
       scanf("%f",&fah);

Write a C Program which explaining Shorthand Notations.

// C Program which explaining Shorthand Notations.

#include<conio.h>
#include<stdio.h>

void main()
{
         int i;
         clrscr();
         printf("Enter the value of i:");
         scanf("%d",&i);
       
         i += 5;
         printf("\n i = %d",i);

Type Casting in C Language

Type Casting
- When user needs the type conversion explicitly, then type casting is used in c programming language.
- Remember that type conversion is automatic while type casting is explicitly specified by the programmer in      program.
- Syntax:
              (type_name) expression;

- Where, type_name is the name of data type we want to convert the expression to.
- The converted value is used during evaluation of expression only.
- It does not change the basic data type of operand(s) of an expression.

- Example:
#include<stdio.h>               
#include<conio.h>

void main()
{
              int sum = 47;
              int number = 10;
              float average;

              clrscr();
              average = sum/number;       
              printf("average = sum/number = %f",average);              
              average = (float)sum/number;
              printf("\n average = (float)sum/number = %f",average);
              
              getch();
}

Operators in C Programming Language

- C Language supports rich set of operators.
- Operators are used in doing various operations.
- The Operators can be divided into different categories.

- These Operators are:
1. Arithmetic Operators.
2. Relational Operators.
3. Logical Operators.
4. Assignment Operator.
5. Conditional Operators.
6. Increment and Decrements Operators.
7. Bit wise Operator.
8. Special Operators.

1. Arithmetic Operators.
         - In C programming, Arithmetic Operators are used in performing mathematical expressions.
         - The c language does not provide the operator for exponentiation.  
         - C language supports following Arithmetic Operators:
            Operator Name                    Meaning
                   +                                  Add
                   -                                   Subtract
                   *                                   Multiply
                   /                                    Divide
                   %                                  Modulo Division.
          - The operator + and - can be used as unary operator also.
          - Except % operator all Arithmetic Operators can be used with any type of numeric operands, while
             % operator can only be used with integer data type only.

Sunday, February 8, 2015

Chapter 1 - Introduction to computer and programming

Introduction
# (pound)
#include<directives>
void
main()
header files
printf()
scanf()
clrscr()
getch()
Concepts of Hardware and software,
Types of softwares,
Compiler and interpreter, 
Concepts of Languages - Machine level, Middle Level and high level
Flow charts,
Algorithms.
Basic block diagram and functions of various components of computer,


Introduction

Introduction of C language.
C was invented by Dennis Ritchie at the Bell Laboratories in 1972.
C became more popular programming language.
C has many powerful features.
It is many times faster than BASIC.

Features of C Language

"Why C is called as middle level language?" explain it.ORExplain Features of C language.

1. C is portable.
- Means if c program is written in one device but it can be run on any devices.
2. C is modular language.