| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:18:38 IST
|
|
|
/*Program to search for a given character*/ #include<iostream.h> #include<conio.h> #include<stdio.h> void main() { char sent[100],ch; int flag=0; cout<<"Enter any sentence\n"; gets(sent); cout<<"Enter the character to be searched\n"; ch=getchar(); for(int i=0;sent[i]!='\0';i++) { if(sent[i]==ch) flag=1; break; } if(flag==1) cout<<"The character "<<ch<<" is present in the sentence"; else cout<<"The character "<<ch<<" is not present in the sentence"; getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:19:26 IST
|
|
|
/*Program to print the series 1+2+3.....n*/ #include<iostream.h> #include<conio.h> void main() { int n; long int sum=0; cout<<"1+2+3.....n\n"; cout<<"Enter the value till which you want to calculate the sum of" <<"of the series(n)\n"; cin>>n; for(int i=0;i<=n;++i) { sum=sum+i; } cout<<"The sum the the series is "<<sum; getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:19:42 IST
|
|
|
/*Program to print the series A AB ABC ABCD*/ #include<iostream.h> #include<conio.h> void main() { char ans='A'; clrscr(); for(int i=1;i<5;++i) { cout<<"\n"; for(int j=1;j<i;++j) { ans=ans+1; cout<<ans; } } getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:20:00 IST
|
|
|
#include<iostream.h> #include<conio.h> void main() { int sales[10]; long total=0,avg=0; clrscr(); cout<<"Enter the sales for ten days"; for(int i=0;i<10;i++) { cin>>sales[i]; total=total+sales[i]; avg=total/10; } cout<<total<<"\t"<<avg; getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:20:18 IST
|
|
|
/*Program to delete a substring*/ #include<iostream.h> #include<conio.h> #include<stdio.h> void main() { char str[50]; int p,del,j,len; clrscr(); cout<<"Enter a sentence\n"; gets(str); for(len=0;str[len]!='\0';++len); cout<<"Enter the starting position of the substring\n"; cin>>p; cout<<"Enter the final position of characters to be deleted"; cin>>del; for(j=p;j<=del;++j) { str[len-1]=str[len-1]-str[j]; } for(len=0;str[len]!='\0';++len) cout<<str[len-1]; getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:20:46 IST
|
|
|
/*Program to print the sum of upper triangle and lower triangle in a matrix*/ #include<iostream.h> #include<conio.h> void main() { int a[3][3],rows,columns,b[3][3],k,l; clrscr(); for(int i=0;i<3;i++) { cout<<" "; for(int j=0;j<3;j++) { cout<<"Enter the "<<i+1<<" "<<j+1<<" element"; cin>>a[i][j]; } } for(k=0;k<3;k++) { for(l=0;l<3;l++) { b[k][l]=0; if(k==l) { b[k][l]+=a[k][l]; cout<<b[k][l]; } } } getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:21:09 IST
|
|
|
#include<iostream.h> #include<conio.h> #include<math.h> void main() { int n,x,ans,fact=0,pro; clrscr(); cout<<"Enter the number till which you want to calculate the cos value"; cin>>n; cout<<"Enter the value of x"; cin>>x; for(int j=1;j<=n;j++) { fact=fact*j; pro=fact; } for(int i=2;i<=n;i+=2) { ans=1-(pow(x,i)/pro); } cout<<cos(ans); getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:21:30 IST
|
|
|
#include<iostream.h> #include<conio.h> void main() { int fib,n,first,second,third=0; clrscr() cout<<"Enter the element till which you want to calculate "; cout<<"the fibonacci series"; cin>>n; first=0; second=1; for(int i=0;i<n;i++) { third=first+second; cout<<third<<" "; first=second; second=third; } getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:21:56 IST
|
|
|
/*Program to print the electric bill*/ #include<iostream.h> #include<conio.h> void main() { char name[20]; int consump; clrscr(); cout<<"Enter the name of the person"; cin>>name; cout<<"\nEnter the amount of units consumed"; cin>>consump; float amount=(consump>300)?0.6:((consump>100)?0.5:0.4); amount=(amount*consump)+50; cout<<"The electric bill for "<<name <<"is"<<amount; getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:22:19 IST
|
|
|
#include<iostream.h> #include<conio.h> void main() { float height; cout<<"Enter your height in cm"; cin>>height; float foot=height/12; int temp=(int)height%12; float inch=temp/2.54; cout<<"The height is"<< foot<<"foot and"<< inch<<"inches"; getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:22:38 IST
|
|
|
#include<grahics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h>
int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax;
/* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "");
/* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); }
setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy();
/* draw a diagonal line */ line(0, 0, xmax, ymax);
/* clean up */ getch(); closegraph(); return 0; }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:23:04 IST
|
|
|
/*Program to multiply two 2*2 matrices*/ #include<iostream.h> #include<conio.h> void main() { int a[5][5],b[5][5],c[5][5]; clrscr(); cout<<"The first matrix\n"; for(int i=0;i<2;i++) { cout<<"\n"; for(int j=0;j<2;j++) { cout<<"Enter the "<<i+1<<"\t"<<j+1<<" element:"; cin>>a[i][j]; } } cout<<"The second matrix\n"; for(int k=0;k<2;k++) { cout<<endl; for(int l=0;l<2;l++) { cout<<"Enter the "<<k+1<<"\t"<<l+1<<" element:"; cin>>b[k][l]; } } cout<<"The resultant is "; for(int m=0;m<2;m++) { for(int n=0;n<2;n++) { c[m][n]+=a[m][n]*b[n][m]; cout<<c[m][n]<<"\t"; } } getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:23:31 IST
|
|
|
/*Program to check if a given word is a palindrome*/ #include<iostream.h> #include<conio.h> void main() { char word[30]; int size=1,flag,space=0; clrscr(); cout<<"Enter any word"; cin.getline(word,80); for(int len=0;word[len]!='\0';++len) { ++space; } cout<<space; for(int j=0,k=size;j<k;++j,--k) { if(word[j]==word[k]) flag=0; } if(!flag) { cout<<"It is a palindrome"; } else { cout<<"It is not a palindrome"; } getch(); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 18 Feb 2008 13:23:51 IST
|
|
|