C++
C++ Program to Print *
/* C++ Program To Print
*
* *
* *
* *
* *
* *
*
*/
#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
clrscr();
int...
>>
———
Program to enter three integers and output the smallest integer using IF
#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int x,y,z,smallest;
cout << "Enter 3 integers : ";
cin>>x>>y>>z;
smallest=x;
if(y<smallest)
smallest=y;
if(z<smallest)
smallest=z;
cout << "The smallest integer out of the 3 integers you typed ";
cout << x...
>>
———
Program to find the sum of either of the diagonals of a 4 x 4 matrix
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int x;
int A[4][4],sum=0; //Reading the matrix.
cout << "Enter the elements of the matrix : " << endl;
for(int y=0;y<4;y++)
for (int x=0;x<4;x++)
{
cout << "Element " << x+1 << ", " <<...
>>
———
Program to enter 10 integers in a single-dimension array and then print out the array in ascending order
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int array[10],t;
for(int x=0;x<10;x++)
{
cout << "Enter Integer No. " << x+1 << " : " << endl;
cin>>array[x];
}
for (x=0;x<10;x++)
{
for(int...
>>
———
Program to enter a sentence and output the number of uppercase & lowercase consonants, uppercase & lowercase vowels in sentence.
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char line[80];
int number_of_vowels,uc,lc,uv,lv;
uc=lc=uv=lv=0;
cout << "Enter your sentence : " << endl;
cin.getline(line,80);
for(int x=0;...
>>
———
Program to convert temperatures from Celsius to Fahrenheit and vice versa
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int choice;
float ctemp,ftemp;
cout << "1.Celsius to Fahrenheit" << endl;
cout << "2.Fahrenheit to Celsius" << endl;
cout << "Choose between 1 & 2 : " << endl;
cin>>choice;
if...
>>
———
Program to print the first 10 lines of pascal's triangle
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
long triangle(int x,int y);
int main()
{
clrscr();
const lines=10;
for (int i=0;i<lines;i++)
for (int j=1;j<lines-i;j++)
cout << setw(2) << " ";
for (int j=0;j<=i;j++)
cout << setw(4) <<...
>>
———
Program to enter a character and output its ASCII code
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char charac;
cout << "Enter the character : " << endl;
cin>>charac;
int num1=charac;
cout << "The ASCII code for " << charac << " is " << num1 << "." << endl;
getch();
}
This...
>>
———
Program to enter a letter and output the next 2 letters
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char charac;
cout << "Enter your letter : " << endl;
cin>>charac;
cout << "The 2 letters are : " << endl;
cout << (char)(charac-1) << endl;
cout << (char)(charac+1) <<...
>>
———
Program to identify if an input is a symbol, digit or character
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char charac;
cout << "Enter your input : " << endl;
cin>>charac;
if(((charac>='A')&&(charac<='Z'))||((charac>='a')&&(charac<='z')))
cout << "Your input " << charac << " is a...
>>