C++ Program to do Addition,subtraction and multiplication of two numbers using function

#include<iostream.h> #include<conio.h> int res; void main() { clrscr(); int sum(int,int); int sub(int,int); int mul(int,int); int a,b,m,su,s; cout<<“Enter two numbers:”; cin>>a>>b; s=sum(a,b); su=sub(a,b); m=mul(a,b); cout<<“Sum:”<<s<<“nSubtraction:”<<su<<“nMultiplication:”<<m; getch(); } sum(int a,int b) { res=a+b; return(res); } sub(int a,int b) { res=a-b; return(res); } mul(int a,int b) { res=a*b; return(res); }

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