Computer Programming
Friday, October 7, 2011
Tuesday, October 4, 2011
And Far Away...
Wow, nice post,there are many person searching about that now they will find enough resources by your post.Thank you for sharing to us.Please one more post about that..Hcg weight loss
Wednesday, March 23, 2011
While statement
The simplest of all the looping structures in is the while statement.
The basic format of while statement is
while (test condition)
{
body of the loop
}
include<stdio.h>
void main( )
{
int sum = 0;
int n = 1;
while (n<=10)
{
sum = sum + n*n;
n = n+1;
}
print f ("sum = %d/n" ; sum);
}
Do-while
The general form of do while loop:
initialization:
do{
statement
increment
} while (condition);
include<stdio.h>
include<conio.h>
void main( )
{
int i = 5;
do { print f ("value of i = %d ", i);
i++
} while (i<5);
print f ("/n current value of i =%d" , i);
getch ( )
}
The basic format of while statement is
while (test condition)
{
body of the loop
}
include<stdio.h>
void main( )
{
int sum = 0;
int n = 1;
while (n<=10)
{
sum = sum + n*n;
n = n+1;
}
print f ("sum = %d/n" ; sum);
}
Do-while
The general form of do while loop:
initialization:
do{
statement
increment
} while (condition);
include<stdio.h>
include<conio.h>
void main( )
{
int i = 5;
do { print f ("value of i = %d ", i);
i++
} while (i<5);
print f ("/n current value of i =%d" , i);
getch ( )
}
Saturday, March 19, 2011
If and Else
Write a program that will read an integer number from the user.The program will examine whether it is an even number or odd number.
include <stdio.h>
include <conio.h>
void main ( )
{
clescr ( );
int number 1, number 2, R;
print f ("please enter two numbers");
scan f ("%d%d",& number 1,& number 2);
R = number 1%2;
if (R= = 0)
print f ("%d is an even number ", number 1);
if (R= = 1)
else
print f ("%d is an odd number", number 1);
print f ("n");
getch ( );
}
R = number 2%2;
if (R= = 0);
print f ("%d is an even number ". number 2);
else
print f (%d is an odd number ". number);
print f ("/n");
getch ( );
}
Program will input the total mark of a student.The program will then perform certain logical test and will print message depending on the test result.
include <stdio.h>
include <conio.h>
void main ( );
{
clrscr ( );
int number ;
print f ("Enter total mark of a student;");
scan f ("%d", & number);
if (number > = 330)
if (number > = 450)
if (number > = 600)
print f ("First division");
else
print f ("Second division");
else
print f ("Third division");
getch ( );
}
include <stdio.h>
include <conio.h>
void main ( )
{
clescr ( );
int number 1, number 2, R;
print f ("please enter two numbers");
scan f ("%d%d",& number 1,& number 2);
R = number 1%2;
if (R= = 0)
print f ("%d is an even number ", number 1);
if (R= = 1)
else
print f ("%d is an odd number", number 1);
print f ("n");
getch ( );
}
R = number 2%2;
if (R= = 0);
print f ("%d is an even number ". number 2);
else
print f (%d is an odd number ". number);
print f ("/n");
getch ( );
}
Program will input the total mark of a student.The program will then perform certain logical test and will print message depending on the test result.
include <stdio.h>
include <conio.h>
void main ( );
{
clrscr ( );
int number ;
print f ("Enter total mark of a student;");
scan f ("%d", & number);
if (number > = 330)
if (number > = 450)
if (number > = 600)
print f ("First division");
else
print f ("Second division");
else
print f ("Third division");
getch ( );
}
Assembler and Complier
The assembler of a computer system is a system software,supplied by the computer manufacturer which translates an assembly language program in to an equivalent machine language program of the computer.
A high level language program must be converted in to its equivalent machine language program before it can be executed on the computer.This translation is done with the help of a translation program,which is known as a compiler.
include <studio.h>
main ( )
{
int number;
print f ("Enter an integer number/n");
scan f ("d%", & number);
if (number <100);
print f ("your number is smaller than 100/n/n");
else
print f ("your number contains more than two light/n");
}
include <studio.h>
define PI 3.1416
main ( )
{
intr;
float area;
print f ("Enter the radius and hight of circle = ");
scan f ("%d", & r );
area = PI * r * r ;
print f ("Area of cylinder = % .2 f ",area);
}
A high level language program must be converted in to its equivalent machine language program before it can be executed on the computer.This translation is done with the help of a translation program,which is known as a compiler.
include <studio.h>
main ( )
{
int number;
print f ("Enter an integer number/n");
scan f ("d%", & number);
if (number <100);
print f ("your number is smaller than 100/n/n");
else
print f ("your number contains more than two light/n");
}
include <studio.h>
define PI 3.1416
main ( )
{
intr;
float area;
print f ("Enter the radius and hight of circle = ");
scan f ("%d", & r );
area = PI * r * r ;
print f ("Area of cylinder = % .2 f ",area);
}
Arithmatic instruction
int a, b, sum;
Float average
a = 10;
b = 25;
c = a;
Sum = a+b+c;
= 45;
Average = 45/3;
= 15.00
Input Instruction:
Scan f ( ) function is used to input integer.
Output Instruction:
Print f ( ) function is used to print.
Variable declaration Instruction:
int a;
float b;
Control Instruction:
> Sequential control instruction.
> Selection control instruction.
> Looping control instruction.
include <stdio.h>
main ( )
{
int number
Print f ("Enter an integer number/n");
Scan f ("%d",& number);
if (number<100)
print f ("your number is smaller than 100/n/n");
else
Print f ("your number contains more than two digits/n");
return 0;
}
Float average
a = 10;
b = 25;
c = a;
Sum = a+b+c;
= 45;
Average = 45/3;
= 15.00
Input Instruction:
Scan f ( ) function is used to input integer.
Output Instruction:
Print f ( ) function is used to print.
Variable declaration Instruction:
int a;
float b;
Control Instruction:
> Sequential control instruction.
> Selection control instruction.
> Looping control instruction.
include <stdio.h>
main ( )
{
int number
Print f ("Enter an integer number/n");
Scan f ("%d",& number);
if (number<100)
print f ("your number is smaller than 100/n/n");
else
Print f ("your number contains more than two digits/n");
return 0;
}
Subscribe to:
Posts (Atom)