Posts

simple tricks in c Programming-Tricks1

  Tricks1 I have been in a fair number of programming courses in my life. Several of these have been in the hallowed C programming language. There was a time when C and C++ were the only languages I could call myself proficient in. Over the years, I have seen a constant pattern in all these courses - they teach you all the basics you should learn, but none of what you will need. For instance, you have been taught to use structures, but not much about how to use them to make sense of vile madness that you might often encounter while coding in C. There is this neat trick I will show you which uses structures and can really simplify working with arrays. There’s something easy you can do with macros to make dynamic allocations tons of times readable. And yes, there are amazing tools right inside  stdio.h  which can make string manipulation much easier. And you can use this trick to implement some radical changes in the way you code C. This is not an article for profession...

Printf and scanf in C Language

  Printf and scanf in C Language ·          printf() and scanf() functions are inbuilt library functions in C programming language which are available in C library by default. These functions are declared and related macros are defined in “stdio.h” which is a header file in C language. ·          We have to include “stdio.h” file as shown in below C program to make use of these printf() and scanf() library functions in C language. 1. PRINTF() FUNCTION IN C LANGUAGE: ·          In C programming language, printf() function is used to print the (“character, string, float, integer, octal and hexadecimal values”) onto the output screen. ·          We use printf() function with  %d  format specifier to display the value of an integer variable. ·          Similarly...

Basic Structure of the C Program

  BASIC STRUCTURE OF A C PROGRAM: Structure of C program is defined by set of rules called protocol, to be followed by programmer while writing C program. All C programs are having sections/parts which are mentioned  below. 1.        Documentation section 2.        Link Section 3.        Definition Section 4.        Global declaration section 5.        Function prototype declaration section 6.        Main function 7.        User defined function definition section EXAMPLE C PROGRAM TO COMPARE ALL THE SECTIONS: You can compare all the sections of a C program with the below C program. /*     Documentation section     C programming basics & structure of C programs     Author: fr...

C Programming Basics

  1. C PROGRAMMING BASICS TO WRITE A C PROGRAM: Below are few commands and syntax used in C programming to write a simple C program. Let’s see all the sections of a simple C program line by line. C Basic commands Explanation #include <stdio.h> This is a preprocessor command that includes standard input output header file(stdio.h) from the C library before compiling a C program int main() This is the main function from where execution of any C program begins. { This indicates the beginning of the main function. /*_some_comments_*/ whatever is given inside the command “/*   */” in any C program, won’t be considered for compilation and execution. printf(“Hello_World!“); printf command prints the output onto the screen. getch(); This command waits for any character input from keyboard. return 0;...