C programming Examples with Output

C programming examples – This section contains solved c programming examples on various c language popular topics. Provided all examples have explanations and output on different user inputs. These programs are important for exams and interview prospective. Programs are all time favourite for computer science students, IT professionals and job seeking guys.

Available programs start from "Hello world" to very upper level, we guarantee you will love these set of programs and these programs will definitely help you to increase your programming skills.

List of available C programming examples with output :

Compile, Run C program in GCC Linux

  1. Write program.
  2. Save program with filename.c (suppose file name is test.c).
  3. Compile program using command gcc test.c -o test
    Here test is the executable (binary) file name.
  4. Run file using command ./test

Compile, Run C program in Turboc2/TurboC3 Windows

  1. Write program.
  2. Save program with filename.c (suppose file name is test.c).
  3. Compile program by pressing ALT+F9.
  4. If program is error free, Run program by pressing CTRL+F9.
  5. See the output by pressing ALT+F5.

Tips to write good programming code

  1. Analyse the problem: many programmer start witting before analysing the problem, this is very bad habit, ignore this always analyse the problem by collecting information from concerned person.
  2. Make algorithm or flow chart: before writing code, make flow chart or algorithm of your logic and code through that.
  3. Documentations: insert proper comments with function name, description, date and time, arguments details. Everything related to code must be there; it will help you or others to understand your code.
  4. Indentations: Code that you had written must be in proper indentation, so that you can read or debug your code easily. Close all braces at the same indent as open. Always insert a tab when you write code within the block.
  5. Define Macros: Always define macros for values, do not use values within the code, macros are easily editable and you can edit values whenever required without changing in the functions.
  6. Initialize all data: Don’t do only declarations, try to assign initial values to them. For examples if you are declaring a variable to store age of the student. Declare with initialization like int age=0;
  7. Use enumeration: Define enum for numerical literals instead of direct literal.
  8. Make functions: always divide your code into small pieces (called function), it will help you to reduce duplicate and you can edit or debug code easily.
  9. Don’t ignore warnings: Some programmers ignored warnings while compiling or running the programs. It is not good for program health a program must have 0 Error and 0 Warning.
  10. Test your program with different inputs: to test program is logically correct or not, test it with different inputs and analyse the output.

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions

We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.