Neeraj Mishra

A crazy computer and programming lover. He spend most of his time in programming, blogging and helping other programming geeks.

C++ Program to do arithmetic operations according to user choice using switch case

include<iostream.h> #include<conio.h> void main() {       clrscr(); int a,b; char c; cout<<“Enter any expression(ex:3*7):”; cin>>a>>c>>b; switch(c) { case’+’: cout<<“nResult:”<<a+b; break; case’-‘: cout<<“nResult:”<<a-b; break; case’*’: cout<<“nResult:”<<a*b; break; case’/’: cout<<“nResult:”<<a/b; break; case’%’:  cout<<“nResult:”<<a%b; break; } getch(); }

C++ Program to convert first letter of each word of a string to uppercase and other to lowercase

#include<iostream.h> #include<conio.h> #include<stdio.h> #include<ctype.h> void main() { clrscr(); int i; char a[30]; cout<<“Enter a string:”; gets(a); for(i=0;a[i]!=’’;++i) { if(i==0) { if(islower(a[i])) a[i]=toupper(a[i]); } else { if(a[i]!=’ ‘) { if(isupper(a[i])) a[i]=tolower(a[i]); } else { i++; if(islower(a[i])) a[i]=toupper(a[i]); } } } cout<<“nnNew string is: “<<a; getch(); }

C++ Program to Concatenate Two Strings

Here you will get C++ program to concatenate two string without using library function. Below program will read two strings from user and then concatenate them to form third string. Output Enter first string:Hello Enter second string:World The concatenated string is HelloWorld