What is the difference between new and malloc?

Friday, August 19th, 2011  »  Posted By  »  Total 2 Comments

Here are the differences between new and malloc, Operator new constructs an object (calls constructor of object), malloc does not. Hence new invokes the constructor (and delete invokes the destructor)This is the most important difference. operator new is an operator, malloc is a function. operator new can be overloaded, malloc cannot be overloaded. operator new […]

C program to Implement Morse code to text conversion and vice-versa.

Sunday, April 4th, 2010  »  Posted By  »  Total 4 Comments

C program to Implement Morse code to text conversion and vice-versa. #include<stdio.h> #include<conio.h> #include<string.h> #include<process.h>   void main() { char str[25],str1[100]; clrscr(); fflush(stdin); printf("enter the String"); gets(str);   int j=0; for(int i=0;i<=strlen(str);++) { switch(toupper(str[i])) { case ‘A’: str1[j++]=’.'; str1[j]=’.'; break;   case ‘b’: str1[j++]=’.'; str1[j++]=’.'; str1[j++]=’.'; str1[j]=’.'; break;   case ‘c’: str1[j++]=’.'; str1[j++]=’.'; str1[j++]=’.'; str1[j]=’.'; […]

C++ program to calculate the factorial of a number using recursion.

Sunday, April 4th, 2010  »  Posted By  »  Total 21 Comments

Write a program to calculate the factorial of a number using recursion. #include<iostream.h> #include<conio.h> void main() { int n,fact; int rec(int); clrscr(); cout<<"Enter the number:->"; cin>>n; fact=rec(n); cout<<endl<<"Factorial Result are:: "<<fact<<endl; getch(); } rec(int x) { int f; if(x==1) return(x); else { f=x*rec(x-1); return(f); } }

C program for Syntax Analyzer

Monday, March 29th, 2010  »  Posted By  »  Total 4 Comments

C program for Syntax Analyzer #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> void main() { int i,j,k=0,count,inc=0,n; char name[30],open[30],ch,chh,o[30]; char op[20]={’=',’+',’-',’*',’/',’%',’^',’&’,'|’}; clrscr(); textcolor(3); cprintf("–Syntax Analyser–"); printf("\n"); printf("\n Enter Syntax"); printf("\n"); scanf("%s",name); n=strlen(name); for(i=0;i<n;i++) { ch=tolower(name[i]); for(j=0;j<9;j++) { if(ch==op[j]) { open[k]=i; o[k]=ch; k++; } } } for(i=0;i<k;i++) { count=open[i]; ch=tolower(name[count-1]); chh=tolower(name[count+1]); if(isalpha(ch)&&isalpha(chh)||isdigit(chh)) ++inc; } if(k==inc) printf("\n %s is a […]

C program for Priority Scheduling

Monday, March 29th, 2010  »  Posted By  »  Total 43 Comments

C program for Priority Scheduling #include<stdio.h> #include<conio.h> #include<iostream.h> void main() { clrscr(); int x,n,p[10],pp[10],pt[10],w[10],t[10],awt,atat,i; printf("Enter the number of process : "); scanf("%d",&n); printf("\n Enter process : time priorities \n"); for(i=0;i<n;i++) { printf("\nProcess no %d : ",i+1); scanf("%d %d",&pt[i],&pp[i]); p[i]=i+1; } for(i=0;i<n-1;i++) { for(int j=i+1;j<n;j++) { if(pp[i]<pp[j]) { x=pp[i]; pp[i]=pp[j]; pp[j]=x; x=pt[i]; pt[i]=pt[j]; pt[j]=x; x=p[i]; p[i]=p[j]; […]

C progrma for First Come First Serve Algorithm

Monday, March 29th, 2010  »  Posted By  »  Total 12 Comments

C progrma for First Come First Serve Algorithm #include<stdio.h> #include<math.h> #include<conio.h> void main() { clrscr(); int p[20],b[20],w[20],t[20],i,v,n,at; int wt=0; float tw,tr; printf("Enter the number of process : "); scanf("%d",&n); printf("enter CPU burst time : "); for(i=1;i<=n;i++) { scanf("%d",&b[i]); t[1]=b[1]; w[1]=0; at=t[1]; wt=w[1]; for(i=2;i<=n;i++) { t[i]=b[i]+t[i-1]; at=at+t[i]; w[i]=t[i-1]; wt=wt+w[i]; } } printf("process \t burst_time \t wait_time […]

C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree

Thursday, March 11th, 2010  »  Posted By  »  Total 24 Comments

/* Write C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree */ #include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; int cost[10][10],i,j,k,n,stk[10],top,v,visit[10],visited[10],u;   main() { int m,c; cout <<"enterno of vertices"; cin >> n; cout <<"ente no of edges"; cin >> m; cout <<"\nEDGES Cost\n"; for(k=1;k<=m;k++) { cin >>i>>j>>c; cost[i][j]=c; } for(i=1;i<=n;i++) […]

Java program of Client-Server network for Chatting between Client and Server

Sunday, October 4th, 2009  »  Posted By  »  Total 18 Comments

BufferedReader cin=newBufferedReader(newInputStreamReader(sk.getInputStream()));
PrintStream cout=new PrintStream(sk.getOutputStream());
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));

Java program that checks whether the given string is palindrome or not

Friday, October 2nd, 2009  »  Posted By  »  Total 16 Comments

StringBuffer s1=new StringBuffer(args[0]);
StringBuffer s2=new StringBuffer(s1);
s1.reverse();
System.out.println(“Given String is:”+s2);
System.out.println(“Reverse String is”+s1);

C graphics program for analog clock

Friday, October 2nd, 2009  »  Posted By  »  Total 3 Comments

Time_Dig[0]=hour/10+48;
Time_Dig[1]=hour%10+48;
Time_Dig[2]=’:';
Time_Dig[3]=min/10+48;
Time_Dig[4]=min%10+48;
Time_Dig[5]=’:';
Time_Dig[6]=sec/10+48;

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: