Skip to content

Instantly share code, notes, and snippets.

View Zulqurnain's full-sized avatar
🤓
I'm Human Seriously

Zulqurnain Haider Zulqurnain

🤓
I'm Human Seriously
View GitHub Profile
@Zulqurnain
Zulqurnain / Problem#2
Created September 18, 2013 14:57
Swap two variables without using third variable. C/ C++
#include <iostream.h>
int main(){
int x=1,y=2;
cout<<"x :=:"<<x<<"\ny :=:"<<y<<"\n";
x+=y;
y=x-y;
x-=y;
cout<<"\nx :=:"<<x<<"\ny :=:"<<y<<"\n";
return 0;
@Zulqurnain
Zulqurnain / Problem#3
Created September 18, 2013 15:05
Write a C++ program to print Hello world without using any semicolon.
#include <iostream.h>
void main(){
switch(printf("HELLO WORLD")){}
}
@Zulqurnain
Zulqurnain / Problem#4
Created September 18, 2013 15:10
Write a C / C++ program to modify the constant variable ?
/*Note : This is a Bug Code ,, in actual it is NOT POSSIBLE !! , this code will only work On MS Visual 2008 & 2010*/
//Sol#1
#include<stdio.h>
int main(){
int i=10;
int *ptr=&i;
*ptr=(int *)20;
printf("%d",i);
@Zulqurnain
Zulqurnain / Problem#1
Created September 18, 2013 15:19
Given a well-formed (non-empty, fully valid) string of digits, let the integer N be the sum of digits. Then, given this integer N, turn it into a string of digits. Repeat this process until you only have one digit left. Simple, clean, and easy: focus on writing this as cleanly as possible in your preferred programming language.
/*Note : Program can take input from binary File*/
#include <iostream>
#include <fstream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main(){ // jUST fOR fUN Zulqurnain jutt Here
long int n,m;
@Zulqurnain
Zulqurnain / C++ Examples#1
Created September 18, 2013 15:31
Seekg() , Tellg() , Seekp() , Seekg()
#include <iostream.h>
#include <fstream.h>
int main()
{
ofstream fout;
int i; char ch;
// File opening in output mode both
fout.open("d:/test.txt",ios::in);
if(!fout)
@Zulqurnain
Zulqurnain / Problem#5
Created September 19, 2013 13:34
Write A Program which Inputs a Number and Tell Us The Following Details : *Positive or Negative *Even or Odd *Perfect or Prime or Not both *Number Or a Character Note : Input Can be a Character so you should perform all check on the ASCII of that character .
#include <iostream.h>
#include <stdlib.h>
int main(){ // By Zulqurnain jutt
int n;
char c[100];
cout<<"Enter Your Number :=:"; cin>>c;
for(int it=0,Fail=0,Pass=0;c[it]!='\0';it++){
@Zulqurnain
Zulqurnain / C++ : Deci To Hex
Last active December 23, 2015 14:29
C++ Code to convert Decimal To Hexa !
#include <iostream.h>
int main(){
int Deci,i=0;
int THex[100]; // Reason To Use : We Need A,B,C,D,E character To Represent Value of HEX
char Hex[100]; // Stores HEX
cout<<"Enter Decimal Number :=:"; cin>>Deci;
int Current_r=Deci , Current_q=Deci;
while(Current_q>=16){ // getting all remainders in array Reversed
@Zulqurnain
Zulqurnain / C++ : Prime Checker
Created September 22, 2013 13:30
Program To Check Entered Number is prime or not !
#include <iostream.h>
int main(){ // Simple Prime Checker
int n;
cout<<"Enter Your Number :=:"; cin>>n;
/*Logic is simple ! if a number is divisible by more than 2 times ,, when approaching it from 1 to n then
its not prime else it is prime .
*/
int t=1,i=0;
@Zulqurnain
Zulqurnain / C++ : Dividing Without Divide Operator
Created September 29, 2013 10:57
Write A C++ Code which perform division of two Integers without Using / (divide operator) .
#include <iostream.h>
#inlcude <math.h>
int main(){ // Done By Zulqurnain jutt
double Numerator , Denominator , Result;
cout<<"Enter Numerator :=:"; cin>>Numerator;
cout<<"Enter Denominator :=:"; cin>>Denominator;
@Zulqurnain
Zulqurnain / C++ : Array of Pointers in Class
Created November 2, 2013 12:34
Private array of pointers set in main !
#include <iostream.h>
#include <string.h>
class student
{
char *arr[5];
public:
void setarr()
{