Armstrong number in PHP
Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers. Let’s try to…
q
Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers. Let’s try to…
#Create a simulator object set ns [new Simulator] #Open a nam trace file set nf [open PING.nam w] $ns namtrace-all $nf #Open a trace file set nt [open PING.tr w]…
#Create a simulator object set ns [new Simulator] #Open a trace file set nt [open lab1.tr w] $ns trace-all $nt #Open a nam trace file set …
#include#include#include#include#include#includevoid sig_handler(int num){printf("nChild Sent a signal to parent:%dn",num);signal(SIGALRM,SIG_DFL);}int main(){int status;system("clear");printf("n--------Signal Handling Across Processes----------n");switch(fork()){case -1:perror("nFork Failed...n");exit(1);break;case 0:alarm(3);kill(getppid(),SIGALRM);//signal(SIGALRM,sig_handler);printf("nIts Child Processn");sleep(5);break;default:signal(SIGALRM,sig_handler);wait(&status);printf("nIts Parent Processn");}return 0;}
#include #include #include #include struct sigaction act; void sighandler(int signum, siginfo_t *info, void *ptr) { printf("Received signal %dn", signum); printf("Signal originates from process %lun", (unsigned long)info->si_pid); } int main() {…
#include #include #include int myfun(const char *pathname,const struct stat *statptr,int type); int main(int argc,char *argv[]) { nftw(argv[1],myfun,0,0); exit(0); } int myfun(const char *pathname,const struct stat *statptr,int type) { if(type==FTW_F) printf("nfile…
#include #include #include int main() { int pid,status; char comd[20];pid=fork(); if(pid==0) { printf("child processn"); while(strcmp(comd,"exit")!=0) { printf("[user@localhost~]$"); gets(comd); system(comd); } exit(0); } else { wait(&status); printf("parent processn"); } } ****************************************…
#!/bin/sh str=tanu echo “string:$str” echo “lengh of string:” z=`expr “$str”:’.*’` echo $z echo “substring is” z=`expr “$str”:’.*(…)’` echo $z echo “position of character n is” z=`expr “$str”:’[^n]*n’` echo $z *******************…
#!/bin/sh if [ $# -ne 1 ] then echo " no arguments " exit fi curdir=`pwd` for dir in `echo $1 | tr '/' ' ' ` do if […
echo "program name: $0" if [ $# -eq 0 ] then exit fi echo "no: of arguments: $#" echo "the input arguments are" num=1 for i in "$@" do echo…