Hi , Every one I really need some help in my programs it doesn't work as I want I know there something wrong in it if you know where the wrong is just show me plz as soon as Possible plzzzzz.
I a Beginner in C++ ;
I will be thankful for you .
------------------------
first program : I need the user to enter his/her full name and then the program separate the string to first name , middle name and the last name which stored in three different strings .
I do it like this ....
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
#include<ctype. h>
#include<string .h>
main()
{
int i=1,j,d=0,k,tmp ,x;
char word[10],f[10],m[10],l[10];
cout<<"Enter Your Full Name\n";
while(cin>>word ){
cout.width('\0' );
cout<<"\n";
if(word!='\0'){
strcpy(f,word);
cout<<"\n Your First Name is.... \n";
cout<<f; }
strcpy(m,word);
cout<<"\n Your Middle Name is.... \n";
cout<<m;
strcpy(l,word);
cout<<"\n Your Last Name is.... \n";
cout<<l;
}
cout<<"\n";
getch();
return 0;
}
*************** *************** *************** *******
second program: it ask the user to enter three word and then arranges the word in alphabetical order using string function to solve this.
I do it like this ....
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
#include<ctype. h>
#include<string .h>
main()
{
int i=1,j,d=0;
char word[10],word1[10],word2[10];
cout<<"Enter How many time you want to do this .... \n";
cin>>j;
for(i=1;i<=j;i+ +){
cout<<"\nEnter First Word\n";
cin>>word;
cout<<"Enter Second Word\n";
cin>>word1;
cout<<"Enter Third Word\n";
cin>>word2;
cout<<"\nGiven word is arranged in alphabetical order\n";
if(strcmp(word2 ,word1)&& strcmp(word2,wo rd) ) {
cout <<word2;
cout<<"\n\n"; }
if(strcmp(word1 ,word)&& strcmp(word1,wo rd2)){
cout <<word1;
cout<<"\n\n";}
if(strcmp(word, word2)&& strcmp(word,wor d1)){
cout<<word;}
cout<<"\n";
cout<<"\t\t *************** *** \n"; }
getch();
return 0;
}
*************** *************** *************
Third program: it Suppose to solve this summation series :
1+2 - 3+4 - 5+6 ...... N
I do it like this
#include <stdio.h>
#include <conio.h>
#define N 3
main()
{
int i,j,d=0,s=0; float sum = 0;
for (i=0; i <= N; i++){
sum +=((d-N)-(((d+i)+1)+((s+ i)+2));
d=2+i;
s=2+i;
}
printf("%d: %4.6f\n", i, sum);
getch();
}
*************** *************** *************** ******
Fourth program : it ask the user to entered two word and exchange the first half a part from word the first string with the second half a part from word the second string also exchange the second half a part from first string with the first half a part string from the second .
I do it like this
#include<iostre am.h>
#include<conio. h>
#include<string .h>
main()
{ int i,j;
cout<<"Enter How many time you want to do this a word";
cin>>j;
for(i=1;i<=j;i+ +) {
cout<<"\nEnter The Words\n";
char word1[6],word2[6],tmp[5],tmp1[5];
cin>>word1;
cin>>word2;
cout<<"\nThe first word is ";
cout<<word1;
cout<<"\nThe second word is ";
cout<<word2;
cout<<" \n\n";
strcpy(tmp1,wor d2);
strncpy(word2,w ord1,3);
cout<<"\n";
cout<<word2;
strcpy(tmp,word 2);
strncpy(word1,t mp1,3);
cout<<"\n";
cout<<" \n\n";
cout<<word1;
cout<<" \n\n"; }
getch();
}
*************** *************** *************** *****
Fifth program: it Suppose to Generate 9 number and then 0,5
Example( a program Generate 055341122 it will be like this 0505341122 or like this 0555341122
I do it like this
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
main()
{
int i,j,d=0,k,tmp;
cin>>j;
while(d<j){
for(i=1;i<=9;i+ +){
k=1+rand()%6;
cout<<k;}
tmp=k;
cout<<tmp;
cout<<"\n";
d++;
}
getch();
return 0;
}
So help me plzzzzzzzzzzzzz zz
I a Beginner in C++ ;
I will be thankful for you .
------------------------
first program : I need the user to enter his/her full name and then the program separate the string to first name , middle name and the last name which stored in three different strings .
I do it like this ....
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
#include<ctype. h>
#include<string .h>
main()
{
int i=1,j,d=0,k,tmp ,x;
char word[10],f[10],m[10],l[10];
cout<<"Enter Your Full Name\n";
while(cin>>word ){
cout.width('\0' );
cout<<"\n";
if(word!='\0'){
strcpy(f,word);
cout<<"\n Your First Name is.... \n";
cout<<f; }
strcpy(m,word);
cout<<"\n Your Middle Name is.... \n";
cout<<m;
strcpy(l,word);
cout<<"\n Your Last Name is.... \n";
cout<<l;
}
cout<<"\n";
getch();
return 0;
}
*************** *************** *************** *******
second program: it ask the user to enter three word and then arranges the word in alphabetical order using string function to solve this.
I do it like this ....
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
#include<ctype. h>
#include<string .h>
main()
{
int i=1,j,d=0;
char word[10],word1[10],word2[10];
cout<<"Enter How many time you want to do this .... \n";
cin>>j;
for(i=1;i<=j;i+ +){
cout<<"\nEnter First Word\n";
cin>>word;
cout<<"Enter Second Word\n";
cin>>word1;
cout<<"Enter Third Word\n";
cin>>word2;
cout<<"\nGiven word is arranged in alphabetical order\n";
if(strcmp(word2 ,word1)&& strcmp(word2,wo rd) ) {
cout <<word2;
cout<<"\n\n"; }
if(strcmp(word1 ,word)&& strcmp(word1,wo rd2)){
cout <<word1;
cout<<"\n\n";}
if(strcmp(word, word2)&& strcmp(word,wor d1)){
cout<<word;}
cout<<"\n";
cout<<"\t\t *************** *** \n"; }
getch();
return 0;
}
*************** *************** *************
Third program: it Suppose to solve this summation series :
1+2 - 3+4 - 5+6 ...... N
I do it like this
#include <stdio.h>
#include <conio.h>
#define N 3
main()
{
int i,j,d=0,s=0; float sum = 0;
for (i=0; i <= N; i++){
sum +=((d-N)-(((d+i)+1)+((s+ i)+2));
d=2+i;
s=2+i;
}
printf("%d: %4.6f\n", i, sum);
getch();
}
*************** *************** *************** ******
Fourth program : it ask the user to entered two word and exchange the first half a part from word the first string with the second half a part from word the second string also exchange the second half a part from first string with the first half a part string from the second .
I do it like this
#include<iostre am.h>
#include<conio. h>
#include<string .h>
main()
{ int i,j;
cout<<"Enter How many time you want to do this a word";
cin>>j;
for(i=1;i<=j;i+ +) {
cout<<"\nEnter The Words\n";
char word1[6],word2[6],tmp[5],tmp1[5];
cin>>word1;
cin>>word2;
cout<<"\nThe first word is ";
cout<<word1;
cout<<"\nThe second word is ";
cout<<word2;
cout<<" \n\n";
strcpy(tmp1,wor d2);
strncpy(word2,w ord1,3);
cout<<"\n";
cout<<word2;
strcpy(tmp,word 2);
strncpy(word1,t mp1,3);
cout<<"\n";
cout<<" \n\n";
cout<<word1;
cout<<" \n\n"; }
getch();
}
*************** *************** *************** *****
Fifth program: it Suppose to Generate 9 number and then 0,5
Example( a program Generate 055341122 it will be like this 0505341122 or like this 0555341122
I do it like this
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
main()
{
int i,j,d=0,k,tmp;
cin>>j;
while(d<j){
for(i=1;i<=9;i+ +){
k=1+rand()%6;
cout<<k;}
tmp=k;
cout<<tmp;
cout<<"\n";
d++;
}
getch();
return 0;
}
So help me plzzzzzzzzzzzzz zz
Comment