NevLabs

Under Construction

NevLabs

Under Construction

NevLabs

Under Construction

NevLabs

Under Construction

NevLabs

Under Construction

Friday, September 30, 2011

Program To search a number in a set of numbers using C


#include<stdio.h>
#include<conio.h>
void main()
{
int  i,n,count=0;
float num[50],search;
clrscr();
printf("how many numbers ?");
scanf("%d",&n);
if(n<=0)
printf("invalid data");
else
{
for(i=0;i<n;i++)
{
printf("Enter the number-%d:",i+1);
scanf("%f",&num[i]);
}
printf("\n\n\nNumber to searched ? ");
scanf("%f",&search);
clrscr();

To Display The Sum Of 1!+2!+3!+.......+n! using C


#include<stdio.h>
#include<conio.h>
double fact(int n);
void main()
{
int n,i;
double sum=0.0;
clrscr();
printf("Up To Which Term ?");
scanf("%d",&n);
for(i=1;i<=n;++i)
sum+=fact(i);
printf("Sum Of The Factorials Of The Numbers Up To %d Is %g",n,sum);
getch();
}
double fact(int n)
{

Factorial of a number using c


#include<stdio.h>
void main()
{
int i,n,fact=1;
clrscr();
printf("Enter the number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
 {
  fact=fact*i;
 }
  printf("%d",fact);
getch();
}

Thursday, September 29, 2011

Students Result Calculation program using PL/SQL


Objective

An examination has been conducted to a class of 5 students and four scores of each student have been provided in the data along with  register number and name. Write a PL/SQL block to do the following
Assign a  letter grade to each student based on the average score;
Average Score     Grade
90-100                   a
75-89                      b
60-74                     c
50-59                     d
0-49                        e

Program

SQL> create table studres(regno number(4) primary key, name varchar(20), paper1 number(2), paper2 number(2), paper3 number(2), paper4 number(2));
Table created
SQL> insert into studres values(1001,’mini’, 23, 49, 44, 46);
1 row created
SQL> insert into studres values(1002,’safeer’, 40, 30, 20, 10);
1 row created
SQL> insert into studres values(1003,’baby’, 49, 39, 46, 45);
1 row created
 SQL> insert into studres values(1004,’danish’, 40, 10, 20, 22);
1 row created

News Paper Vendor program using PL/SQL


Objective

 Every morning a newspaper vendor newspapers in wholesale from a distributor for 60 paise. He sells them in retail for 75 paise. At the end of the day the unsold papers are returned to the distributor for 30 paise rebate per paper. Write a PL/SQL code block to prepare a report for the newspaper vendor in the following format with 5 weeks data.
Week     Bought      Sold        Return        Profit        Loss
       1                   60                  30         
      2                   75                  40
        .                     .                      .
program:

SQL>Create table vendor (week number(2) primary key, bought number(2), sold number(2));
Table created.
SQL>inser into vendor values(1,100,75);
1 row created.
SQL>insert into vendor values(2,70,60);
1 row created.
SQL>insert into vendor values(3,45,20);
1 row created.
SQL>insert into vendor values(4,60,55);
1 row created.
SQL>insert into vendor values(5,50,50);
1 row created.
SQL>ALTER TABLE vendor add(return number(10), profit number(6,2), loss number(6,2));
Table altered.
SQL> ed news;
        declare

Salary Report program using PL/SQL


Objective

A salary statement contains Name, Basic pay , allowance total , deduction
(include , IT ),  gross pay, and net pay .
Allowance      =    20% of basic pay
gross pay       =   Basic pay + Allowance.
Deduction      =  10% of basic pay
income tax is calculated on the basis of annual income under the following condition.

annual salary                                                      Income tax
  < =300,000                                                           Nil
  >30,000 but <55,000                                         30% of excess over the amount Rs = 30,000/-
 >=55,000                                                                50% of excess over the amount Rs = 55,000/-


program:

SQL > Create table salary (empno number (5) primary key , name varchar(20), basis pay
number (10,2));
Table Created.
SQL> Insert into . salary values (1001 , 'Baby' ,15,000);
1 row Created
SQL > Insert into salary values (1002, 'Hanna', 20,000);
1 row Created
SQL>insert into salary values (1003, 'chinnu',6000);
1 row Created
SQL > insert into salary values (1004, 'megha', 400,000);
1 row Created.
SQL > Insert into salary values (1005, 'swetha', 5200);
1 row Created.
SQL > ALTER TABLE salary add (allowance number (10,2) , deduction number (10,2),gross pay number (10,2), net pay number (10,2), income tax number (10,2));
Table Altered.
SQL > ed Sal;
declare
        v-allw  salary allowance%type ;
        v-gp  salary gross pay%type ;
        v-ded salary deduction%type ;
         v-net salary net pay%type ;
         v-inc salary income tax%type
 cursor c selected  *  from  salary ;
an in number (10,2);
begin