GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 125 of 255    Print  
Write a program to concatenate two strings.

  
Total Answers and Comments: 1 Last Update: October 01, 2007   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: renji_reshma
 
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
char name[50],fname[15],sname[15],lname[15];
int i,j,k;
clrscr();
printf("First name:");
gets(fname);
printf("Second name:");
gets(sname);
printf("Last name:");
gets(lname);

for(i=0;fname[i]!='';i++)
name[i]=fname[i];
name[i]=' ';

for(j=0;sname[j]!='';j++)
name[i+j+1]=sname[j];
name[i+j+1]=' ';

for(k=0;lname[k]!='';k++)
name[i+j+k+2]=lname[k];
name[i+j+k+2]='';

printf("nn");
printf("Complete name after concatenation:n");
printf("%s",name);


getche();
}


Above answer was rated as good by the following members:
s22453220
October 01, 2007 12:44:45   #1  
renji_reshma Member Since: October 2007   Contribution: 3    

RE: Write a program to concatenate two strings.
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
char name[50],fname[15],sname[15],lname[15];
int i,j,k;
clrscr();
printf("First name:");
gets(fname);
printf("Second name:");
gets(sname);
printf("Last name:");
gets(lname);

for(i=0;fname[i]!='';i++)
name[i]=fname[i];
name[i]=' ';

for(j=0;sname[j]!='';j++)
name[i+j+1]=sname[j];
name[i+j+1]=' ';

for(k=0;lname[k]!='';k++)
name[i+j+k+2]=lname[k];
name[i+j+k+2]='';

printf("nn");
printf("Complete name after concatenation:n");
printf("%s",name);


getche();
}

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    

 Related Questions

Latest Answer : All the solutions above are reading the source code with the files concepts.find a solution where you do not have a source file to read the contents.There is a macro or an attiribute which tells the compiler the name of the program, function or the attribute. ...

Latest Answer : In C it is System("program_to_run.exe"); In Windows it can be ShellExecute(); or WinExec(); ...

Latest Answer : In Linux/Unix , we have the header file dirent.h.This .h file contains the direcory manipulation functions Some of the functions are opendir,closedir,readdir. ...

Latest Answer : #include main(int argc, char *argv[]){  printf("Removing: %s...n", argv[0]);  remove(argv[0]);} ...

Latest Answer : 7150u have to worry because this is a master program i had created when i started with c ...

Latest Answer : You can write Multithreading application by using POSIX library of Linux ...

Latest Answer : typedef enum {read,blue,green}color; void main() { color a = 1;    // Error in C++} ...

Where does global, static, local, register variables, free memory and C Program instructions get stored?

Latest Answer : *(*(*(*(a+i)+j)+k)+l) ...
Tags : Pointer

Latest Answer : The advantages of using pointers are: 1: you can work with the address of the variable2: you can reference the variables in more different easiest ways....    e.g  int a[10],*b;                b=&a;         if you want to refer ...


 Sponsored Links

 
Related Articles

OOPS Tutorials

Object oriented programming OOP is a computer science term used to characterize a programming language that began development in the 1960&rsquo; s The term object oriented programming&rsquo; was originally coined by Xerox PARC to designate a computer application that describes the methodol
 

How to develop compile and run a C program

The steps involved in building a C program are: 1. First program is created by using any text editor and the file is stored with extension as .c 2. Next the program is compiled. There are many compilers available&nbsp;like GNU C compiler called as gcc, Sun compiler, Borland compiler which is pop
 

Quality Aspects to Check While Writing COBOL Program

Quality Aspects to Check While Writing COBOL Program This article gives a general list which the programmer must check while delivering programs developed in COBOL This can also be used as a general checklist for checking quality of the COBOL program developed mosgoogle Quality is a vital factor fo
 

PHP Tutorials : Strings (Part 2)

PHP Tutorials Strings Part 2 In this PHP Tutorial you will learn about Strings 2nd Part String cleanup String replacement Case functions String formatting and&nbsp; A list of the available type specifiers mosgoogle String cleanup String cleanup is removing n r t 0 and spaces from any side of t
 

PHP Tutorials - Strings (Part I)

PHP Tutorials Strings Part I In this PHP Tutorial you will learn about Strings viz The heredoc syntax String length String position Strings comparison String search and Substring selection mosgoogle The heredoc syntax PHP has another way to specify strings called heredoc syntax The heredoc syntax is
 

The Inheritance Concept In OOPs

The Inheritance Concept In OOPs In object oriented programming objects will be characterised by classes It is possible to learn a lot about an object based on the class it belongs to Even if you are not familiar with the name Maybach If I told you it is a car you would immediately know that it has f
 

Understanding The Message Concept In OOPs

Understanding The Message Concept In OOPs To understand object oriented programming you will need to become familiar with messages As the name implies a message is a process in which software objects will communicate with one another Because of this having one object is not enough mosgoogle An objec
 

Basic concepts of OOPS and Structure of C++ program

Basic concepts of OOPS and Structure of C program In this tutorial you will learn about Objects Classes Inheritance Data Abstraction Data Encapsulation Polymorphism Overloading Reusability Before starting to learn C it is essential that one must have a basic knowledge of the concepts of Object orie
 

Online Degree Program Information

Online Degree Program Information While the concept of distance learning is not recent the use of the internet to earn degrees online is a relatively new concept The beginning of what would become a revolution in education started in the middle of the 1990s mosgoogle It was during this time that hig
 

Exforsys Certification Practice Program Version 1 Uploaded

Exforsys Certification Practice Version 1 Uploaded We are glad to let you know that we have completed Certification Testing Module changed and bug fixes It s now avaiable for download and practice for the exams from your home PC We are giving this program for free at no charge all we ask in return y
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape