C++
Source code
How to print only integer type values on output screen using code blocks or you can also use Turbo c/c++ in this program you user can not enter any character on output screen.
#include<iostream>
#include<conio.h>
#include<windows.h>
using namespace std;
main()
{
int n;
cout<<"Enter a Value: ";
n=getche();
system("cls");
for (int i=48;i<=57;i++)
{
if(n==i){
cout<<(char)n;}
}
}
How to swap to variable without using third variable and this code i just made in one line.
#include<iostream>
using namespace std;
main()
{
int a=10,b=20;
cout<<"Before swap"<<"a= "<<a<<"b= "<<b;
b=(a-b+(a=b));
cout<<"After swap"<<"a= "<<a<<"b= "<<b;
}
How to make GOTOxy function to print text at any position.
How to play sound/music in some simple steps.
How to print all ASCII codes.
#include<iostream>
using namespace std;
main()
{
for(int i=0;i<=255;i++) // i<=255 because ASCII is start with 0 to 255
{
// (char)i means we want to print the character of it is called type casting
cout<<(char)i;
}
}
How to make password protected program.
#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdio.h>
using namespace std;
main()
{
char s[20],s2[]="Password",ch;
int i;
cout<<"Entered your password: ";
gets(s);
cout<<endl<<"Password you entered is: "<<s;
if(strcmp(s,s2)=='\0')
cout<<endl<<"Access Granted";
else
cout<<endl<<"Wrong password";
}
How to print text without semicolons.
In just one line.
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
if(cout<<"HELLO"&&getch()){}
}
How to print capital letters only.
#include<iostream>
#include<conio.h>
#include<windows.h>
using namespace std;
main()
{
char ch;
ch=getche();
system("cls");
for (int i=1;i<=26;i++)
{
if(ch==i+96)
ch=i+64;
}
cout<<ch;
}
Graphical program in different style.
#include<graphics.h>
#include<iostream>
main()
{
int gd=0,gm=0;
initgraph(&gd,&gm,"");
circle(200,200,50);
getch();
closegraph();
}
HAPPY VALENTINES DAY.....♥♥♥
SORRY source code can't upload on the site.
How to print text with changing text color and gotoxy.
#include<graphics.h>
#include<iostream>
main()
{
int gd=0,gm=0;
initgraph(&gd,&gm,"");
circle(200,200,50);
getch();
closegraph();
}