 ## Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

Call +91 74 88 34 7779  | Email : anishsingh@live.com

Website URL: http://toshiyas.in
Thursday, 08 February 2018 05:03

### Classification of Computers | Type of Computer Computers differ based on their data processing abilities. They are classified according to purpose, data handling and functionality.

According to purpose, computers are either general purpose or specific purpose. General purpose computers are designed to perform a range of tasks. They have the ability to store numerous programs, but lack in speed and efficiency. Specific purpose computers are designed to handle a specific problem or to perform a specific task. A set of instructions is built into the machine.

According to data handling, computers are analog, digital or hybrid. Analog computers work on the principle of measuring, in which the measurements obtained are translated into data. Modern analog computers usually employ electrical parameters, such as voltages, resistances or currents, to represent the quantities being manipulated. Such computers do not deal directly with the numbers. They measure continuous physical magnitudes. Digital computers are those that operate with information, numerical or otherwise, represented in a digital form. Such computers process data into a digital value (in 0s and 1s). They give the results with more accuracy and at a faster rate. Hybrid computersincorporate the measuring feature of an analog computer and counting feature of a digital computer. For computational purposes, these computers use analog components and for storage, digital memories are used.

According to functionality, Type of computers are classified as :

## Analog Computer

An analog computer (spelt analogue in British English) is a form of computer that uses continuous physical phenomena such as electrical, mechanical, or hydraulic quantities to model the problem being solved.

## Digital Computer

A computer that performs calculations and logical operations with quantities represented as digits, usually in the binary number system

## Hybrid Computer (Analog + Digital)

A combination of computers those are capable of inputting and outputting in both digital and analog signals. A hybrid computer system setup offers a cost effective method of performing complex simulations.

## Analog Computer

An analog computer (spelt analogue in British English) is a form of computer that uses continuous physical phenomena such as electrical, mechanical, or hydraulic quantities to model the problem being solved.

## Digital Computer

A computer that performs calculations and logical operations with quantities represented as digits, usually in the binary number system

## Hybrid Computer (Analog + Digital)

A combination of computers those are capable of inputting and outputting in both digital and analog signals. A hybrid computer system setup offers a cost effective method of performing complex     simulations.

On the basis of Size: Type of Computer

## Super Computer

The fastest and most powerful type of computer Supercomputers are very expensive and are employed for specialized applications that require immense amounts of mathematical calculations. For example, weather forecasting requires a supercomputer. Other uses of supercomputers include animated graphics, fluid dynamic calculations, nuclear energy research, and petroleum exploration.

The chief difference between a supercomputer and a mainframe is that a supercomputer channels all its power into executing a few programs as fast as possible, whereas a mainframe uses its power to execute many programs concurrently.

## Mainframe Computer

A very large and expensive computer capable of supporting hundreds, or even thousands, of users simultaneously. In the hierarchy that starts with a simple microprocessor (in watches, for example) at the bottom and moves to supercomputers at the top, mainframes are just below supercomputers. In some ways, mainframes are more powerful than supercomputers because they support more simultaneous programs. But supercomputers can execute a single program faster than a mainframe.

## Mini Computer

A midsized computer. In size and power, minicomputers lie between workstations and mainframes. In the past decade, the distinction between large minicomputers and small mainframes has blurred, however, as has the distinction between small minicomputers and workstations. But in general, a minicomputer is a multiprocessing system capable of supporting from 4 to about 200 users simultaneously.

## Micro Computer or Personal Computer

Desktop Computer: a personal or micro-mini computer sufficient to fit on a desk.

Laptop Computer: a portable computer complete with an integrated screen and keyboard. It is generally smaller in size than a desktop computer and larger than a notebook computer.

Palmtop Computer/Digital Diary /Notebook /PDAs: a hand-sized computer. Palmtops have no keyboard but the screen serves both as an input and output device.

## Workstations

A terminal or desktop computer in a network. In this context, workstation is just a generic term for a user's machine (client machine) in contrast to a "server" or "mainframe."

Tuesday, 06 February 2018 07:19

### Block Diagram of Computer

computer can process data, pictures, sound and graphics. They can solve highly complicated problems quickly and accurately. A computer as shown in Fig.  performs basically five major computer operations or functions irrespective of their size and make. These are

it accepts data or instructions by way of input,
it stores data,
it can process data as required by the user,
it gives results in the form of output, and
it controls all operations inside a computer.

We discuss below each of these Computer operation 1. Input: This is the process of entering data and programs in to the computer system. You should know that computer is an electronic machine like any other machine which takes as inputs raw data and performs some processing giving out processed data. Therefore, the input unit takes data from us to the computer in an organized manner for processing.

2. Storage: The process of saving data and instructions permanently is known as storage. Data has to be fed into the system before the actual processing starts. It is because the processing speed of Central Processing Unit (CPU) is so fast that the data has to be provided to CPU with the same speed. Therefore the data is first stored in the storage unit for faster access and processing. This storage unit or the primary storage of the computer system is designed to do the above functionality. It provides space for storing data and instructions.

The storage unit performs the following major functions:

All data and instructions are stored here before and after processing.

• Intermediate results of processing are also stored here.

3. Processing: The task of performing operations like arithmetic and logical operations is called processing. The Central Processing Unit (CPU) takes data and instructions from the storage unit and makes all sorts of calculations based on the instructions given and the type of data provided. It is then sent back to the storage unit.

4. Output: This is the process of producing results from the data for getting useful information. Similarly the output produced by the computer after processing must also be kept somewhere inside the computer before being given to you in human readable form. Again the output is also stored inside the computer for further processing.

5. Control: The manner how instructions are executed and the above operations are performed. Controlling of all operations like input, processing and output are performed by control unit. It takes care of step by step processing of all operations inside the computer.

## FUNCTIONAL UNITS

In order to carry out the operations mentioned in the previous section the computer allocates the task between its various functional units. The computer system is divided into three separate units for its operation. They are

### Arithmetic Logical Unit (ALU)

Logical Unit :After you enter data through the input device it is stored in the primary storage unit. The actual processing of the data and instruction are performed by Arithmetic Logical Unit. The major operations performed by the ALU are addition, subtraction, multiplication, division, logic and comparison. Data is transferred to ALU from storage unit when required. After processing the output is returned back to storage unit for further processing or getting stored.

### Control Unit (CU)

The next component of computer is the Control Unit, which acts like the supervisor seeing that things are done in proper fashion. Control Unit is responsible  for  co ordinating various operations using time signal. The control unit determines the sequence in which computer programs and instructions are executed. Things like processing of programs stored in the main memory, interpretation of the instructions and issuing of signals for other units of the computer to execute them. It also acts as a switch board operator when several users access the computer simultaneously. Thereby it coordinates the activities of computer’s peripheral equipment as they perform the input and output.

### Central Processing Unit (CPU)

The ALU and the CU of a computer system are jointly known as the central processing unit. You may call CPU as the brain of any computer system. It is just like brain that takes all major decisions, makes all sorts of calculations and directs different parts of the computer functions by activating and controlling the operations.

Tuesday, 06 February 2018 05:14

### Introduction to Computer

What is Computer : Computer is an electronic device that is designed to work with Information. The term computer is derived from the Latin termcomputare’, this means to calculate or programmable machineComputer can not do anything without a Program. It represents the decimal numbers through a string of binary digits. The Word 'Computer' usually refers to the Center Processor Unit plus Internal memory.

Charles Babbage is called the "Grand Father" of the computer. The First mechanical computer designed by Charles Babbage was called Analytical Engine. It uses read-only memory in the form of punch cards.

Computer is an advanced electronic device that takes raw data as input from the user and processes these data under the control of set of instructions (called program) and gives the result (output) and saves output for the future use. It can process both numerical and non-numerical (arithmetic and logical) calculations. ## Digital Computer Definition

The basic components of a modern digital computer are: Input Device, Output Device, Central Processor Unit (CPU), mass storage device and memory. A Typical modern computer uses LSI Chips.  Four Functions about computer are:

Input (Data):

Input is the raw information entered into a computer from the input devices. It is the collection of letters, numbers, images etc.

Process:

Process is the operation of data as per given instruction. It is totally internal process of the computer system.

Output:

Output is the processed data given by computer after data processing. Output is also called as Result. We can save these results in the storage devices for the future use.

Computer Classification: By Size and Power

Computers differ based on their data processing abilities. They are classified according to purpose, data handling and functionality.

According to functionality, computers are classified as:

Analog Computer: A computer that represents numbers by some continuously variable physical quantity, whose variations mimic the properties of some system being modeled.

Personal computer: personal computer is a computer small and low costThe term"personal computer" is used to describe desktop computers (desktops).

Workstation: A terminal or desktop computer in a network. In this context, workstation is just a generic term for a user's machine (client machine) in contrast to a "server" or "mainframe."

Minicomputer: minicomputer isn't very mini. At least, not in the way most of us think of mini. You know how big your personal computer is and its related family.

Mainframe: It refers to the kind of large computer that runs an entire corporation.

Supercomputer: It is the biggest, fastest, and most expensive computers on earth.

Microcomputer: Your personal computer is a microcomputer.

Tuesday, 06 February 2018 04:55

### Computer Fundamental

Friday, 02 February 2018 05:04

## Using Tables

• A table is defined using the `<table>` element, and contains a number of table cells ( `<td>`, for “table data” ) which are organized into table rows ( `<tr>`). The markup (HTML code) for a table is always based on rows, never columns.
• Table cells which act as column headers or row headers should use the `<th>` (table header) element.
• Table cells can be merged using the `colspan` and `rowspan` attributes.
• Tables can be broken into sections using the following elements:
• `<thead>` — Table header
• `<tbody>` — Table body
• `<tfoot>` — Table footer
• A caption can be added to a table using the `<caption>` element.
• You can use `<col>` and `<colgroup>` to define table columns for styling. However, there are a number of limitations with this practice.

## Table Code Sample: Simple Table

``````<table>
<tr>
<th>Name</th>
<th>Favorite Color</th>
</tr>
<tr>
<td>Bob</td>
<td>Yellow</td>
</tr>
<tr>
<td>Michelle</td>
<td>Purple</td>
</tr>
</table>
``````
Name Favorite Color
Bob Yellow
Michelle Purple

## Table Code Sample: Complex Table

``````<table>
<caption>A complex table</caption>
<tr>
<th colspan="3">Invoice #123456789</th>
<th>14 January 2025
</tr>
<tr>
<td colspan="2">
<strong>Pay to:</strong><br>
Acme Billing Co.<br>
123 Main St.<br>
Cityville, NA 12345
</td>
<td colspan="2">
<strong>Customer:</strong><br>
John Smith<br>
321 Willow Way<br>
Southeast Northwestershire, MA 54321
</td>
</tr>
<tbody>
<tr>
<th>Name / Description</th>
<th>Qty.</th>
<th>@</th>
<th>Cost</th>
</tr>
<tr>
<td>Paperclips</td>
<td>1000</td>
<td>0.01</td>
<td>10.00</td>
</tr>
<tr>
<td>Staples (box)</td>
<td>100</td>
<td>1.00</td>
<td>100.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="3">Subtotal</th>
<td> 110.00</td>
</tr>
<tr>
<th colspan="2">Tax</th>
<td> 8% </td>
<td>8.80</td>
</tr>
<tr>
<th colspan="3">Grand Total</th>
<td>\$ 118.80</td>
</tr>
</tfoot>
</table>
``````
A complex table
Invoice #123456789 14 January 2025
Pay to:
Acme Billing Co.
123 Main St.
Cityville, NA 12345
Customer:
John Smith
321 Willow Way
Southeast Northwestershire, MA 54321
Name / Description Qty. @ Cost
Paperclips 1000 0.01 10.00
Staples (box) 100 1.00 100.00
Subtotal 110.00
Tax 8% 8.80
Grand Total \$ 118.80

It was common in the early days of the web to use tables as a layout device. Before the advent of modern standards-based browsers, this was the easiest way to make sure that page elements were arranged properly on the screen.

This design pattern is now considered very bad. It is bad for the user experience, bad for SEO, and bad for developers who have to maintain pages.

However, that doesn’t mean you should avoid tables — tables should be used whenever you need to present information in a tabular format.

Friday, 02 February 2018 04:37

### Beginners HTML Tutorials

Our HTML tutorials teach you how to create a personal website or site for your business, without forcing you to learn unnecessary theory. We’ll get you building your new website in minutes, not hours.

Our most popular beginners tutorials include:-

• HTML tables
• Forms
• Fonts
• Images

We’ve plenty of topics for intermediate and advanced HTML learners, too:-

• CSS tutorials, to make your HTML page look beautiful
• Javascript for beginners
• HTML5: What’s New?
• Semantic Markup
• Logical tags
Thursday, 21 September 2017 05:56

### C -for-Program

Print the first five numbers starting from I together with their squares.

`#include<stdio.h>#include<conio.h>Void main ( ){       Int  I;       Clrscr ( );       For (i=l; <=5; i++)       Printf (“\n  Number:  %5d  it’ s  Square:  %5d”, I, i*i);      getch();}`

OUTPUT:

Number:  1  it’ s  Square:  1

Number:  2  it’ s  Square:  4

Number:  3  it’ s  Square:  9

Number:  4  it’ s  Square:  16

Number:  5  it’ s  Square:  25

`#include<stdio.h>#include<conio.h>Valid main ( ){        Int  I;        Clrscr ( ) ;        For ( i=l; i<=15; i= i+l)        Printf (“%5d”,i);        getche ( );}`

OUTPUT:

1 2 3 4 5 6 7 8 9 10 11 12 13 14  15

Write a program to display even numbers from 0 to 14.  Declare the initial counter value before the for loop statement.

`#include<stdio.h>#include<conio.h>Void main ( ){        Int  i=o ;        Clrscr ( );        For (i<=15;)        {                  Printf (“% 5 d “ , i) ;                  i+=2;        }}`

OUTPUT:

O 2 4 6 7 8 10 12 14

Write a program to count numbers between 1 to 100 not divisible by 2, 3, and 5.

`#include<stdio.h>#include<conio.h>Void main ( ){     Int  x, c=0;     Clrscr ( );     Printf (“\n  Numbers  from  1  to  100  not  divisible  by  2, 3  &  5 \n \n”);     For (x=0  ;x<=100 ;x ++)     {            If (x%2 !=0   &&  x%3!=0  && x%5!=0)            {                Printf (%”%d\t” ,x),                C++;            }     }     Printf (“\nTotal numbers  :  %d”, c );}`

OUTPUT:

Numbers  from  1  to  100  not  divisible  by 2, 3  &  5

1    7    11    13    17    19    23    29    31    37     37

41   43    47    49    53     59    61    67    71     73

77    79    83    89   91    97

Total  Numbers  :  26

Write a program to display the numbers in increasing and decreasing order using the infinite for loop.

`#include<stdio.h>#include<conio.h>           Void main ( ){       Int  n, a, b;       Clrscr ( );       Printf (“Enter  a  number  :”);       Scanf (“, &);       A=b=n;       Printf (“ (++)  ( - - ) \n”);       Printf (“============”);       For (;  ;  (a++, b - - ) )       {             Printf (“\n%d\t%d”, a, b);             If (b==0)             Break;       }}`

OUTPUT:

Enter  a  number  :  5

(++)         ( - - )

===========

5    5

6    4

7    3

8    2

9    1

10  0

create an infinite for loop.  Check each value of the for loop.  If the value is even display it otherwise continue with iterations.  Print Even numbers from 1 to 21.  Use break statement to terminate the program.

`#include<stdio.h>#include<conio.h>Void main ( ){       Int  i=l;       Clrscr ( );       Printf (“\n \t \t  Table  of  Even  numbers  from  1  to  20”);       Printf (“\n \t \t  ===== == ==== ======= ==== = == == \n”);       For (;  ;)       {           If (i==21)           Break;           else  if (i%2==0)           {                 Printf (“%d\t”, i);                 I++;                 Continue;           }           else           {                I++;                Continue;           }    }    getche ( );}`

OUTPUT:

Table  of  Even  numbers  from  1  to  20

====  ==  ====  =======  ===  =  ==  ==

2  4  6  8  10  12  14  16  18  20

Calculate the sum of the first five numbers and their squares. Display their results.

`Void main ( ){        Int  I,  sum=0, sqsum=0;        Clrscr ( );        For (i=l; i<-5; ++)        {               Sum+-I;               Sqsum+=i*I;               Printf (“\n  number:  %5d  it’ s  Square  :  %8d”, I, i*i);       }       Printf (“\n===================================”);       Printf (“\n  The  sum  of  the  five  numbers (1  t0  5)  : -%6d”, sum);       Printf (“\n  The  sum  of  their  Squares: -%9d”,  sqsum);       getche ( );}`

OUTPUT:

Number:             1                 it’ s  Square:             1

Number:             2                 it’ s  Square:             4

Number:             3                 it’ s  Square:             9

Number:             4                 it’ s  Square:            16

Number:             5                 it’ s  Square:            25

=========================================

The  sum  of  the  five  numbers (1  t0  5) : -  15

The  sum  of  their  Squares: -  55

Write a program to find the number in between 7 and 100 which is exactly divisible by 4 and

If divided by 5 and 6 remainders obtained should be 4.

`#include<stdio.h>#include<conio.h>#  include  <process . h>Void main ( ){       Int  x;       Clrscr ( );       For (x=7;x<100;x++)       {              If (x%4==0  &&  x%5==4  &&  x%6==4)              {                     Printf (“\n  Number  :  %d”, x);              }      }     getche ( );}`

OUTPUT:

Number  :  64

Write a program to find the sum of the following series.

`/*  1.  1+2+3+ ..n  *//*  2.  12+22+32+..n2  */#include<stdio.h>#include<conio.h>Void main ( ){       Int  sum=0, ssum-0, I, j;       Clrscr ( );       Printf (“Enter  Number  :”);       Scanf (“%d”,  &j);       Clrscr ( );       Printf (“  Numbers:”);       For (i=1; i<=j; i++)       Printf (“%5d”, i);       Printf (“\n \nSquares:”);       For (i=1; i<=j; i++)       {            Printf (“%5d”, i*i);            Sum=sum+I;            Sum=ssum+i*i;       }       Printf (“\n \nSum  of  Numbers  from  1  to  %d  :%d”, j, sum);       Printf (“\nSum  of  Squares  of  1  to  %d  Numbers  :%d”, j, ssum);}`

OUTPUT:

Enter  Number:  5

Numbers:  1  2  3  4  5

Squares:  1  4  9  16  25

Sum  of  Numbers  from  1  to  5:  15

Sum  of  Squares  of  1  to  5  Numbers:  55

Write a program to find the perfect squares from 1 to 500.

`#include<stdio.h>#include<conio.h># include  <math . h>Void maid ( ){      Int  I, count, x;      Float  c;      Clrscr ( );      Printf (“\n \n”);      Printf (“  Perfect  squares  from  1  to  500 \n”);      For (i=1; <=500; i++)  {      C=sqrt (i);       X=floor (c);  /*  For  rounding  up  floor ( )  is  used.  */       {              Printf (“\t%5d”, i);              Coun ++;      }  }  Printf (“\n \n  Total  Perfect  Squares  =5d\n”, conut);  getch ( );}`

OUTPUT:

1       4      9      16      25   36   49   64   81   121   144

169   196   225    256    289   324    361    400   441

484

Total  Perfect  Squares  =  22

Write a program to detect the largest number out of five numbers and display it.

`#include<stdio.h>#include<conio.h># include<process . h>Void main ( )Exit (0);{       Int  a, b, c, e, sum=0, I;       Clrscr ( );       Printf (“\nEnter  Five  numbers  :”);       Scanf (“%d  %d  %d  %d  %d”, &a, &b, &c, &d, &e);       For (i=sum;  i<=sum; I - -)       {             If (i==a  ||  i==b  ||  i==c  ||  i==d  ||  i==e)             {                   Printf (“The  Largest  Number  :  %d”, i);                   Exit (0);             }      }}`

OUTPUT:

Enter  Five  number  :  5  2  3  7  3

The  Largest  Number  :  7

Write a program to detect the smallest number our of five numbers and display it.

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  a, b, c, d, e, sum=0, I;      Clrscr ( );      Printf (“\nEnter  Five  numbers  :”);      Scanf (“%d  %d  %d  %d  %d”, &a, &b, &c, &d, &e);      Sum=a+b+c+d+e;      For (i=l;  i<=sum; i++)      {            If (i==a  ||  i==b  ||  i==c  ||  i==d  ||  i==e)            {            Printf (“The  Smallest  Number  :  %d”, i)            Exit (0);            }      }}`

OUTPUT:

Enter  Five  numbers  :  5  2  3  7  3

The Smallest  Number:  2

Write a program to print the five entered numbers in the ascending order.

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  a, b, c, d, e, sum-0, I;      Clrscr ( );      Printf (“\nEnter  Five  numbers  :”);      Scanf (“%d  %d  %d  %d  %d” &a, &b, &c, &d, &e);      Printf (“\n  Numbers  in  ascending  order  :”);      Sum=a+b+c+d+e;      For (i=l;  i<=sum; i++)  {     If (i==a  ||  i==b  ||  i==c  ||  i==d  ||  i==e)     {             Printf (“%3d”, i);     }  }}`

OUTPUT:

Enter  Five  numbers  :  5  8  7  4  1

Numbers  in  ascending  order  :  1  4  5  7  8

Perform multiplication of two integers by using the negative sign.

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  a, b, c, d=0;      Clrscr ( );      Printf (“\n  Enter  two  numbers  :”);      Scanf (“%d  %d”,  &a, &b);      For (c=l; c<-b; c++)      D= (d) – ( - a);      Printf (“Multiplication  of  %d  *  %d  :%d”, a, b, d);      getche ( );}`

OUTPUT:

Enter  two  numbers  :  5  5

Multiplication  of  5  *  5  :  25

Calculate the sum and average of five subjects.

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  a, b, c, d, e, sum=0, I;      Float  avg;      Clrscr ( );      Printf (“\nEnter  The  Marks  of  Five  Subjects”);      For (i=l; i<=5; i++)      {           Printf (“\n [%d]  Student:”, i);           If (scanf (“%d  %d  %d  %d  %d”, &a, &b, &c, &d, &e) ==5)           {                 Sum=a+b+c+d+e;                 Avg=sum/5;                 Printf (“\n  Total  Marks  of  Student [%d]  %d”, I, sum);                 Printf (“\n  Average  Marks  of  Student [%d]  %f\n”, I, avg);           }           else           {                Clrscr ( );                Printf (“\n  Type  Mismatcch”);           }     }}`

OUTPUT:

Enter  The  Marks  of  Five  Subjects

 Student:  58  52  52  56  78

Total  Marks  of  Student   296

Average  Marks  of  Student   59.000000

 Student:

Write a program to find perfect cubes up to a given number.

`/* 1, 8, 27, 64 are perfect cubes of 1, 2, 3 and 4 */.#include<stdio.h>#include<conio.h>#  include<math . h>Void main ( ){      Int  I,  j,  k;      Clrscr ( );      Printf (“Enter  a  Number  :”);      Scanf (“%d”, &k);      For (i=l; i<k; i++)      {            For (j=l; j<=I; j++)            {                 If (i==pow (j,3) )                 Printf (“\nNumber  :  %d  &   it’ s  Cube  :%d:, j, i);            }     }}`

OUTPUT:

Enter  a  Number  :  100

Number  :  1  &  it’ s  Cube  :  1

Number  :  2  &  it’ s  Cube  :  8

Number  :  3  &  it’ s  Cube  :  27

Number  :  4  &  it’ s  Cube  :  64

Write a program to display the stars as shown below.

*

*  *

*  *  *

*  *  *  *

*  *  *  *  *

`#include<stdio.h>#include<conio.h>Void main ( ){       Int  x, I, j;       Clrscr ( );       Printf (“How  many  lines  stars  (*)  should  be  printed  ?  :”);       Scanf (“%d”, &x);       For (i=l; i<=x; i++)       {              For (j=l; j<=I; j++)              {                     Printf (“*”);              }              Printf (“\n”);       }}`

OUTPUT:

How  many  lines  stars  (*)  should  be  printed  ?  :  5

*

*  *

*  *  *

*  *  *  *

*  *  *  *  *

Write a program to generate the pattern of numbers as given under.

6  5  4  3  2  1  0

5  4  3  2  1  0

4  3  2  1  0

3  2  1  0

2  1  0

1  0

0

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  I, c=0;      Clrscr ( );      Printf (“Enter  a  Number  :”);      Scanf (“%d, &i);      For (;i>=0i - -)      {            C=I;            Printf (“\n”);            For (;  ;)            {                   Printf (“%3d”, c);                   If (c==0)                   Break;                   C- -;            }      }}`

OUTPUT:

Enter  a  number:  6

6  5  4  3  2  1  0

5  4  3  2  1  0

4  3  2  1  0

3  2  1  0

2  1  0

1  0

Write a program to display the series of numbers as given below.

1

1  2

1  2  3

1  2  3  4

4  3  2  1

3  2  1

2  1

1

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  I, j, x;       Printf (“\nEnter  Value  of  x  :”);      Scanf (“%d”,&x);      Clrscr ( );      For (j=l; j<=x; j++)      {             For (i=l; i<=j; i++)             Printf (“%3d”, i);             Printf (“\n”);     }     Printf (“\n”);     For (j=x; j>=l; I - -)     {            For (i=j; i>=l; I- -)            Printf (“%3d”, i);            Printf (“\n”);     }} `

OUTPUT:

1

1  2

1  2  3

1  2  3  4

4  3  2  1

3  2  1

2  1

1

Write a program to display the series of numbers as given below.

1

1  2

1  2  3

1  2  3  4

4  3  2  1

3  2  1

2  1

1

`#include<stdio.h>#include<conio.h>Void main ( ){     Int  I, j, x;     Printf (“\nEnter  Value  of  x  :”);     Scanf (“%d”, &x);     Clrscr ( );     For (j-l; j<=x; j++)     {           For (i=j; i>=l; I - -)           {                 Printf (“%3d”, i);           }           Printf (“\n”);     }}`

OUTPUT:

Enter  Value  of  x  :  4

1

1  2

1  2  3

1  2  3  4

4  3  2  1

3  2  1

2  1

1

Write a program to generate the pyramid structure using numerical.

`#include<stdio.h>#include<conio.h>Void main ( ){      Int  k, I, j, x, p=34;      Printf (“\n  Enter  A  number  :”);      Scanf (“%d”, &x);      Clrscr ( );      For (j=0; j <=x; j++)      {             Gotoxy(p, j+l);             /*  position  cursor  on  screen  (x  cordinate, y  cordinate)  */            For (i=0 – j; I <=j; i++)            Printf (“%3d”, abs ( I ) );            P=p-3;     }}`

OUTPUT:

Enter  a  number  :  3

0

1  0  1

2  1  0  1  2

3  2  1  0  1  2  3

Tuesday, 19 September 2017 05:11

### nested loops in C

C programming allows to use one loop inside another loop. The following section shows a few examples to illustrate the concept.

## Syntax

The syntax for a nested for loop statement in C is as follows −

```for ( init; condition; increment ) {

for ( init; condition; increment ) {
statement(s);
}

statement(s);
}
```

The syntax for a nested while loop statement in C programming language is as follows −

```while(condition) {

while(condition) {
statement(s);
}

statement(s);
}
```

The syntax for a nested do...while loop statement in C programming language is as follows −

```do {

statement(s);

do {
statement(s);
}while( condition );

}while( condition );
```

A final note on loop nesting is that you can put any type of loop inside any other type of loop. For example, a 'for' loop can be inside a 'while' loop or vice versa.

## Example

The following program uses a nested for loop to find the prime numbers from 2 to 100 −

```#include <stdio.h>

int main () {

/* local variable definition */
int i, j;

for(i = 2; i<100; i++) {

for(j = 2; j <= (i/j); j++)
if(!(i%j)) break; // if factor found, not prime
if(j > (i/j)) printf("%d is prime", i);
}

return 0;
}```

When the above code is compiled and executed, it produces the following result −

```2 is prime
3 is prime
5 is prime
7 is prime
11 is prime
13 is prime
17 is prime
19 is prime
23 is prime
29 is prime
31 is prime
37 is prime
41 is prime
43 is prime
47 is prime
53 is prime
59 is prime
61 is prime
67 is prime
71 is prime
73 is prime
79 is prime
83 is prime
89 is prime
97 is prime```
Tuesday, 19 September 2017 05:09

### do...while loop in C

Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming checks its condition at the bottom of the loop.

do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time.

## Syntax

The syntax of a do...while loop in C programming language is −

```do {
statement(s);
} while( condition );
```

Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop executes once before the condition is tested.

If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop executes again. This process repeats until the given condition becomes false.

## Flow Diagram ## Example

```#include <stdio.h>

int main () {

/* local variable definition */
int a = 10;

/* do loop execution */
do {
printf("value of a: %d\n", a);
a = a + 1;
}while( a < 20 );

return 0;
}```

When the above code is compiled and executed, it produces the following result −

```value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19```
Tuesday, 19 September 2017 05:07

### for loop in C

for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

## Syntax

The syntax of a for loop in C programming language is −

```for ( init; condition; increment ) {
statement(s);
}
```

Here is the flow of control in a 'for' loop −

• The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears.

• Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and the flow of control jumps to the next statement just after the 'for' loop.

• After the body of the 'for' loop executes, the flow of control jumps back up to the increment statement. This statement allows you to update any loop control variables. This statement can be left blank, as long as a semicolon appears after the condition.

• The condition is now evaluated again. If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the 'for' loop terminates.

## Flow Diagram ## Example

```#include <stdio.h>

int main () {

int a;

/* for loop execution */
for( a = 10; a < 20; a = a + 1 ){
printf("value of a: %d\n", a);
}

return 0;
}```

When the above code is compiled and executed, it produces the following result −

```value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19```
Page 1 of 32