Sunday 10 August 2014

C Programming for Beginners - 1 | C Language Tutorial for Beginners

C Programming for Beginners - 1 | C Language Tutorial for Beginners



https://www.youtube.com/watch?v=qlp8_zlMnSk


Robert Sebesta Web technology text book




https://www.dropbox.com/s/n68k0y135s86e0o/Programming%20the%20World-Wide%20Web-Sebesta%20Robert.rar

Write an awk script to compute gross salary of an employee accordingly to rule given below. If basic salary is < 10000 then HRA=15% of basic & DA=45% of basic. If basic salary is >=10000 then HRA=20% of basic & DA=50% of basic.


BEGIN{
printf"enter the basic salary:Rs"
getline bp<"/dev/tty"
if(bp<10000)
{
hra=.15*bp
da=.45*bp
}
else
{
hra=.2*bp
da=.5*bp
}
gs=bp+hra+da
printf"gross salary=Rs.%.2f\n",gs

Write an awk script to find out total number of books sold in each discipline as well as total book sold using associate array down table as given below. Electrical 34 Mechanical-1 67 Electrical-1 80 Computer Science 43 Mechanical 65 Civil-1 198 Civil 198 Computer Science-1 64


BEGIN{
printf "enter the mechanical books:"
getline mc <"/dev/tty"
printf "enter the electrical books:"
getline ec <"/dev/tty"
printf "enter the computer books:"
getline cs <"/dev/tty"
printf "enter the civil books:"
getline ci <"/dev/tty"
}
{
if(NR==1)
tot1=$2-mc
if(NR==2)
tot2=$2-ec
if(NR==3)
tot3=$2-cs
if(NR==4)
tot4=$2-ci
}
{
if(NR==4)
{
printf "total mechanical books present:%d\n",tot1
printf "total electrical books present:%d\n",tot2
printf "total computer books present:%d\n",tot3
printf "total civil books present:%d\n",tot4
}
}

Write an awk script to delete duplicated line from a text file. The order of the original Lines must remain unchanged.


BEGIN {i=1}
{
flag=1;
for(j=1;j<i && flag ; j++)
{
if(x[j]==$0)
flag=0;
}
if (flag)
{
x[j]=$0;
printf("\n%s",x[i]);
i++;
}
}

Write an awk script that accepts date argument in the form of mm-dd-yy and displays it in the form if day, month, and year. The script should check the validity of the argument and in the case of error, display a suitable message.


BEGIN {
FS="-"
f=1;
printf("enter date with (mm-dd-yy) format:");
getline < "/dev/tty"
if(((($3%4!=0) && ($1==2) && ($2>28)) || (($3%4==0) && ($1==2) && ($2>29))) ||
((($1==1) || ($1==3) || ($1==5) || ($1==7) || ($1==8) || ($1==10) || ($1==12)) && ($2>31)) ||
((($1==4) || ($1==6) || ($1==9) || ($1==11)) && ($2>30)) || ($1<1) || ($2<1) || ($3<1) || ($1>12))
f=0;
if(f==0)
printf("you have entered an invalid date\n");
else
printf("\n \tThe date= %d\nThe month=%d\nThe year is=%d\n is valid date\n",$2,$1,$3);
}

 
- |