Skip to content

Instantly share code, notes, and snippets.

View Zulqurnain's full-sized avatar
🎯
Focusing

Zulqurnain Haider Zulqurnain

🎯
Focusing
  • Rave Business Systems LLC
  • Lahore, Pakistan
View GitHub Profile
@Zulqurnain
Zulqurnain / C: Paragraph Details
Created January 20, 2014 20:47
C code to take paragraph as an input from user and do the following: 1.count total number of character 2.count total number of spaces 3.count total number of string (are)
#include<stdio.h>
#include<conio.h>
void main(void){ // by zulqurnain jutt
char* arr=new char[200]; // you can use pointer for longer strings
printf("\n::Start Entering Your Paragraph Now::\n\t");
int i=0,j=0,NoofChars=0,Noofspaces=0,NoofStrings=0;
while(arr[i]=getch()){
if(arr[i]!=13){
// escape sequence \n can't be used as '\n' in this case so use its Ascii 13
@Zulqurnain
Zulqurnain / C++: Paragraph details
Created January 17, 2014 12:46
C++ code to take paragraph as an input from user and do the following: 1.count total number of character 2.count total number of spaces 3.count total number of string (are)
#include<iostream>
using namespace std;
int main(void){ // by zulqurnain jutt
char arr[200]; // you can use pointer for longer strings
cout<<"\n::Start Entering Your Paragraph Now::\n\t";
cin.getline(arr,200,'\n');
int i=0,j=0,NoofChars=0,Noofspaces=0,NoofStrings=0;
for(;arr[i]!=0;i++,NoofChars++){
if(arr[i]==' '){
@Zulqurnain
Zulqurnain / Java:Paragraph details
Last active April 10, 2016 18:56
Java code to take paragraph as an input from user and do the following: 1.count total number of character 2.count total number of spaces 3.count total number of string (are)
package basics;
import java.util.*;
class Basics{ // by Zulqurnain jutt
public static void main(String argv[]) {
String s;
Scanner sc=new Scanner(System.in);
System.out.print("::Start Entering Paragraph from Here::\n\t"); s=sc.nextLine();
char[] c=s.toCharArray();
System.out.print("\nTotal Character :=:"+c.length+"\nTotal Spaces :=:"+ (s.length()-s.replace(" ", "").toCharArray().length));
@Zulqurnain
Zulqurnain / Java: Randomize Numbers
Last active January 3, 2016 09:39
Java Program to print the Random Number between given starting and ending value.
package basics;
import java.util.*;
import javax.swing.JOptionPane;
class Basics { // done by Zulqurnain jutt
public static void main(String[] args) {
String s;
int si,ei,numi;
s=JOptionPane.showInputDialog(null, "\t::Starting Range::\t");
@Zulqurnain
Zulqurnain / C++: Number in triangle form
Created January 13, 2014 15:11
C++ program to print: 13579 3579 579 79 9
#include<iostream>
using namespace std;
int main(){ // done by Zulqurnain jutt
int Number=13579;
for(int i=Number,j,count=1;i!=0;count=1){
for(j=i;j!=0;j/=10,count*=10){}
cout<<i<<"\n";
count/=10;
i%=count;
}
@Zulqurnain
Zulqurnain / C++: Separating Integer
Created January 12, 2014 19:05
C++ code to Separately Print Integer Number with spaces and Count its Numbers
#include<iostream>
#include <fstream>
using namespace std;
int main(){ // By Zulqurnain jutt
int Number,count=0,*Num;
cout<<"Enter Any Integer Number :=:"; cin>>Number; cout<<"\n";
int temp=1;
bool Negative=0; // if negative
@Zulqurnain
Zulqurnain / C++: Add number without any operator
Created January 10, 2014 09:41
C++ code to add Two number without using any operator .
#include<iostream>
using namespace std;
/*
Reason: when we are doing p[i] it is actually equall to *(p+i) ,
similarly when we are doing &p[i] it is equal to (p+i) so giving address,
when we do &((&p[a])[b]) is it equall to (p+a+b) , p=0 so 0+a+b = a+b ,
i have used integer type casting because pointer p was of character type
*/
@Zulqurnain
Zulqurnain / C++: Tokenize any string
Created December 22, 2013 17:29
Tokenize the given string by removing special characters.
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cout<<"Enter The String :=:"; getline(cin,s,'\n'); cout<<"\n";
for(int i=0;s[i]!=0;i++){
if((s[i]>=48 && s[i]<=57)||(s[i]>=65 && s[i]<=90)||(s[i]>=97 && s[i]<=122)){
cout<<s[i];
@Zulqurnain
Zulqurnain / C++: 1st sub string
Created December 21, 2013 22:27
Find The First Palindrome Sub string in a given string.
#include <iostream>
#include <string.h>
using namespace std;
char* substring(char* s){
char* temp;
int location = 0,j=0;
int size = 0;
for ( int i = 1; i < strlen(s) - 1; i++ ) {
int left = i;
@Zulqurnain
Zulqurnain / C++ : Longest Sub string Palindrom
Created December 21, 2013 22:12
Find The Longest Palindrome sub string in a Given string.
#include <iostream>
#include <string.h>
using namespace std;
char* Longpali(char* s){
char* temp;
int location = 0,j=0;
int maxsize = 0;
for ( int i = 0; i < strlen(s) - 1; i++ ) {
int left = i;