Share This

Random Programming Tips For Beginners

While the programming courses in our university and other universities in Nepal give good basic foundation for programming, they lack the chapters on approach to better programming practices. In this post, I'll list some better programming practices intended for beginner programmers.


Select the proper variable and functions name so that it would be easier for you as well as other programmers to read your code. Remember you will start to puzzle if you check back your own unmanaged code.

Follow a proper convention for naming and STICK to it. You can follow any variables naming convention but you should always stick to it. (Some basic variable naming conventions are:
int iNum, char strName[40]
int i_num, char str_name[40]
It does not matter which you follow. What matters is how consistent you follow the convention.

Think before you code and sketch the structure of your program. Flowcharts, algorithms, pseudo-codes, etc. can prove great work before coding.

Don't ignore compiler warnings as those warnings probably indicate that your executable might be buggy in runtime.

Make the habit of writing comments as it would make the program even more clearer for others and yourself as well. But do not write excessive and unnecessary comments. Don't write comments in the lines that are self-explanatory.

Indent your source code as proper indentation makes your code look neat and increases readability.

Multiply rather than dividing as multiplication is generally faster than division.

If you've got any useful tips, leave them as comment and we'll add your tips in the post.
Continue Reading...

Character to ASCII IN CHAR() Format

This is a small code snippet that can be used to get the ASCII equivalent of your characters in the char() format which can be useful while performing SQL Injection.

//ascii maker for sql injection
//change the string part in the source code as per your need
// this can be used to create char() string for sql injection and this will come along with the video
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char str[1024];
    int len;
    int i;
    FILE *fp;
    fp = fopen("sqlinj.txt","a+");
    if (fp == NULL)
    {
           printf("Error opening file");
           exit(1);
    }
    else
    {
        printf("ASCII CHAR() MAKER FOR SQL INJECTION");
        printf("\n\t\tBy SAM207");
        printf("\nEmail: samar_acharya[at]hotmail.com");
        printf("\n\nEnter the string: ");
        gets(str);
        len = strlen(str);
        for (i = 0; i<len;i++)
        {
            fprintf(fp,"char(%d),",str[i]);
        }
        fprintf(fp,"\n\n");
        fclose(fp);
    }
    printf("File successfully written");
    getch();
}
Continue Reading...

Hello World In Different Languages

As with the famous trend of writing hello world as the first program in every beginner's site, we've written hello world programs in various different languages. So enjoy.

C
#include <conio.h>
int main()
{
printf("Hello World\n");
getch();
}

C#
class Hello {
  static void Main() {
    System.Console.Write("Hello World");
  }
 }

C++
#include <iostream>

using namespace std;

int main()
 {
  cout << "Hello, World." << std::endl;
 }

JAVA
public class Hello {
   public static void main(String []args) {
   System.out.println("Hello World");
   }
 }

Javascript
document.writeln("Hello, World");

PERL
print "Hello World\n"

PHP
<?php echo "Hello World"; ?> 

Python
print "hello world"

Ruby
puts "Hello, world"

Shell Scripting
#!/bin/sh
 echo "Hello World"

You can leave your addition in the comment section.
Continue Reading...

Followers