Language

C++ Program – CheckSum generator

May 11, 2011

//Downloaded From theonlinetutorials.com //Source code #include<iostream.h> #include<stdio.h> #include<string.h> #include<conio.h> #define size 100 unsigned short int checksum(char []); void valch(unsigned short int check,char message[]); int main(){ clrscr(); cout<<” Enter any thing :”; char message[size]={0}; cin>>message; unsigned short int check=checksum(message); getch(); valch(check,message); getch(); return 0; } void valch(unsigned short int check,char message[]){ unsigned short int t[size],ch=0; int [...]

Read the full article →

C Program – Adding two no without using + operator

May 11, 2011

//Downloaded From theonlinetutorials.com //Source code #include<stdio.h> #include<conio.h> int main() { clrscr(); int a=3000,b=20,sum; char *p; p=(char *)a; sum= (int)&p[b]; //adding a & b printf(“Answer is :”); printf(“%d”,sum); getch(); return 0; }

Read the full article →

C++ Program – Remove duplication of the word

May 11, 2011

//Downloaded From theonlinetutorials.com //Source code #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> void dop(char s[]) { char a[100],b[100]; a[0]=NULL; b[0]=NULL; int flag=0,sa=0; for(int i=0;i<=strlen(s);i++) { if(s[i]==’ ‘||s[i]==NULL) { b[sa]=’ ‘; sa++; b[sa]=NULL; flag=1; } else { b[sa]=s[i]; sa++; } if(flag==1) { if(strcmp(a,b)==0) { for(int j=(i-sa);j<=strlen(s);j++) { s[j]=s[j+sa]; } i=i-sa; } flag=0; sa=0; strcpy(a,b); } } } int main() [...]

Read the full article →

C++ Program – Display Fun Stars

May 11, 2011

//Downloaded From theonlinetutorials.com //Source code #include<iostream.h> #include<conio.h> int main() { int n,i,j; cout<<”Enter an integer value below 200 :”; cin>>n; for(i=0;i<n;i++) { for( j=0;j<i;j++) cout<<” “; cout<<”*”; for( j=1;j<=2*(n-i)-1;j++) { cout<<” “; } cout<<”*”; cout<<endl; } for(j=0;j<i;j++) cout<<” “; cout<<”*”<<endl; for(i=n-1;i>=0;i–) { for( j=0;j<i;j++) cout<<” “; cout<<”*”; for( j=1;j<=2*(n-i)-1;j++) { cout<<” “; } cout<<”*”; cout<<endl; [...]

Read the full article →

C program – Calculate the factorial of a number using recursion

May 11, 2011

//Downloaded From theonlinetutorials.com //Source code #include”stdio.h” #include”conio.h” int fac(int n){ if(n<0) return 0; if(n==1||n==0) return 1; else return n*fac(n-1); } int main() { int n=5; int i; printf(“Enter the no to find the factorail \n”); scanf(“%d”,&n); printf(“Factorail of the no is %d “,fac(n)); getch(); return 0; }

Read the full article →

C Program – Print fun with pyramid

May 9, 2011

//Downloaded From theonlinetutorials.com #include”stdio.h” #include<conio.h> void main() { int a; int i,j,k; clrscr(); printf(” Enter an integer value: “); scanf(“%d”,&a); for(i=0;i<=2*a+1;i++) printf(“*”); printf(“\n”); for(i=1;i<=a-1;i++) { for(j=a;j>=i;j–) printf(“*”); printf(” “); for(j=a;j>=i;j–) printf(“*”); printf(“\n”); } printf(“*Theonlinetutorials.com \n”); for(i=2;i<=a;i++) { for(j=1;j<=i;j++) printf(“*”); printf(” “); for(j=1;j<=i;j++) printf(“*”); printf(“\n”); } for(i=0;i<=2*a+1;i++) printf(“*”); getch(); }

Read the full article →

C Program – Find whether a given number is a multiple of 3 or not

May 9, 2011

//Downloaded From theonlinetutorials.com #include”stdio.h” #include”conio.h” #include”math.h” void main() { int n; clrscr(); printf(” Enter a number: “); scanf(“%d”,&n); n=abs(n); while(n>3) n-=3; if(n==3) printf(“no is multiple of 3″); else printf(“no is not multiple of 3″); getch(); }

Read the full article →

C Program – Timer program with loop breaking

May 9, 2011

//Downloaded From theonlinetutorials.com #include “stdio.h” #include “conio.h” #include “dos.h” int main() { int i,flag=0; char s[100]; clrscr(); for(i=30;i>=0;i–) { if(kbhit()) { scanf(“%s”,s);//User want to take input flag=1;//Call the operation you require break;//Terminate the loop } delay(1000); printf(“\n00:%2d”,i); } if(flag==1) printf(“User entered %s”,s);//If user entered a value display it getch(); return 0; }

Read the full article →

C Program – Timer program

May 9, 2011

//Downloaded From theonlinetutorials.com #include “stdio.h” #include “conio.h” #include “dos.h” int main() { int i; char s[100]; clrscr(); for(i=30;i>=0;i–) { delay(1000); printf(“\n00:%2d”,i); } printf(“Timer finished”); getch(); return 0; }

Read the full article →

C++ Program – Find the 2 largest number from the given set of numbers

May 9, 2011

//Downloaded From theonlinetutorials.com #include<iostream.h> #include<conio.h> int main() { int a[1000],n,max,max1; cout<<”How many no you will input”<<endl; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } //Escape When two input are not avaliable if(n<=1) { cout<<”Maximu two No are”<<endl; for(int i=0;i<n;i++) { cout<<a[n]<<endl; } return 0; } //store maximu value between a[0] and a[1] max=a[0]>a[1]?a[0]:a[1]; max1=a[0]<a[1]?a[0]:a[1]; for(i=2;i<n;i++) { if(a[i]>max1) [...]

Read the full article →

C Program – Call a function before main

May 9, 2011

//Downloaded From theonlinetutorials.com #include<stdio.h> #include<conio.h> void v(void); #pragma startup v int main() { printf(“    You are in Main”); getch(); return 0; } void v(void) { clrscr(); printf(“You are in v”); }

Read the full article →

C Program – Display all type of pyramids

May 9, 2011

//Downloaded From theonlinetutorials.com #include<stdio.h> #include<conio.h> void main() { int n=6,k,i,j; clrscr(); printf(“How many star you want “); scanf(“%d”,&n); for(i=1;i<=n;i++) { printf(“\n”); for(j=1;j<=i;j++) printf(” *”); } getch(); for(i=1;i<=n;i++) { printf(“\n”); for(k=n;k>=i;k–) printf(” “); for(j=1;j<=i;j++) printf(” *”); } getch(); for(i=1;i<=n;i++) { printf(“\n”); for(k=n;k>=i;k–) printf(” “); for(j=1;j<=i;j++) printf(“*”); } printf(“\n”); getch(); for(i=1;i<=n;i++) { printf(“\n”); for(k=1;k<=i;k++) printf(” “); for(j=n;j>=i;j–) [...]

Read the full article →

C Program – Print the number which are not occurred in Fibonacci Series

May 9, 2011

//Downloaded From theonlinetutorials.com #include<stdio.h> int fib(int n) { if(n==1) return 0; if(n==2) return 1; else return fib(n-2)+fib(n-1); } int main() { int n,on=0,nn,cou,i; printf(“Enter the no to which you want to print all no which did not occur in fib series”); scanf(“%d”,&n); cou=1; printf(“\nNumber which are not occured in the series are\n”); while((nn=fib(cou))<=n) { cou++; [...]

Read the full article →

C++ Program – Matrix Multiplication

May 9, 2011

//Downloaded From theonlinetutorials.com #include<iostream.h> #include<conio.h> #define size 100 void dis(int *a,int r1,int c1) { for(int i=0;i<r1;i++) { for(int j=0;j<c1;j++) { cout<<*(a+i*size+j)<<”\t”; } cout<<endl; } } void getd(int *a,int *r1,int *c1) { cout<<”Enter no of row”; cin>>*r1; cout<<”Enter no of col”; cin>>*c1; cout<<”Now enter the data”; for(int i=0;i<*r1;i++) { for(int j=0;j<*c1;j++) { cin>>*(a+i*size+j); } cout<<endl; } [...]

Read the full article →

C Program – Random Float number Generator

May 9, 2011

//Downloaded From theonlinetutorials.com #include”stdio.h” #include”stdlib.h” #include”time.h” #include”limits.h” float Frand(int n) { float m; m=(float)(rand())/RAND_MAX; m+=rand()%n; return m; } float Frand1(int n) { float m,temp; temp=(float)rand()/RAND_MAX; m=n*temp; return m; } int main() { int  n,i; printf(“Enter a int no to which you want to generate an random float no”); scanf(“%d”,&n); printf(“This program will be tested 10 [...]

Read the full article →

Nesting of loops in C++

May 7, 2011

When a loop is written inside other loop, then the representation is know as the nesting of looping constructs. In this representation,the child loop is executed fully and then the control is transferred to its parent loop for the next repetition. Example program: #include<iostream.h> #include<conio.h> void main() { char ans=’y’; int x=1,y; while(ans!=’n’||ans!=’N’) { count<<”Enter [...]

Related Posts Plugin for WordPress, Blogger...
Read the full article →