Skip to main content

what is C language and its inroduction.

INTRODUCTION to C

C is a general-purpose programming language that is extremely popular, simple and flexible. It is machine-independent, structured programming language which is used extensively in various applications.

C was the basic language to write everything from operating systems (Windows and many others) to complex programs like the Oracle database, Git, Python interpreter and more.

Why learn 'c'?

'C' is a base language for many programming languages. So, learning 'C' as the main language will play an important role while studying other programming languages. It shares the same concepts such as data types, operators, control statements and many more. 'C' can be used widely in various applications. It is a simple language and provides faster execution.


How 'c' Work?

A is a compiled language.

A compiler is a special tool that compiles the program and converts it into the object file which is machine readable. After the compilation process, the linker will combine different object files and creates a single executable file to run the program.

Where?


    1. Visual studio code (free source code editor)https://code.visualstudio.com/download

    2.             https://www.electronicshub.org/download-turbo-cwindows/

    3.             Dev C++

    4.             Online gdb – online compiler



  Structure of a PROGRAM
  1. Contains one or more functions, where a function is defined a group of C statement thart are executed together.
    2. main() - function 
    3. All function has Two parts-declaration section and statement section.
  First C program.

                                    #include<stdio.h>................................  1

Int main()...........................   2

{

 3 printf(“Hello world”);

                                return 0...........................    4

                                }  ............................... 5

1.            
Preprocessor

2.             Int main()

3.             Group all the related statements of the function main. 



Files used in a C program.
 
HEADER FILE

      Header file is a file that contains function declaration and 

         macro definition for C in-built library functions.

      All C standard library functions are declared in many header files 

        which are saved as file_name.h.

      We are including these header files in our C program using 

        “#include <file_name.h>” command to make use of the           functions  those are declared in the header files.

      When we include header files in our C program using “#include 

       <filename.h>” command, all C code of the header files are 

         included in C program. Then, this C program is compiled by  

           compiler and executed.


#include<stdio.h>

    stdio is standard for input/output, this allows us to use some commands 

      which includes a file called stdio.h. or

    This is a preprocessor command. That notifies the compiler to include 

       the header file stdio.h in the program before compiling the source-code.

int/viod main()

                                  •    int/void is a return value.

                      main()

                                   •    The main() is the main function where program execution                                                                 begins. Every C program must contain only one main function.                                                or

                                   •    This is the main function, which is the default entry point for                                             every C program and the void in front of it indicates that it does                                         not return a value.

Braces

                                     •      Two curly brackets "{...}" are used to group all statements. or

                                     •      Curly braces which shows how much the main() function has                                                 its  scope.

return  0 

         At the end of the main function return value 0.






Comments

Popular posts from this blog

C program to find prime factors of a number

  Write a C program to input a number from user and find Prime factors of the given number using loop. C program to list all prime factors of a given number. Logic to find prime factors of a number in C programming. Example Input Input any number: 10 Output Prime factors of 10: 2, 5 Required knowledge Basic C programming ,  If statement ,  For loop ,  Nested loop What is Prime factor? Factors of a number  that are  prime numbers  are called as Prime factors of that number. For example: 2 and 5 are the prime factors of 10. Logic to check prime factors of a number Step by step descriptive logic to find prime factors. Input a number from user. Store it in some variable say  num . Run a loop from  2  to  num/2 , increment 1 in each iteration. The loop structure should look like  for(i=2; i<=num/2; i++) . You may think why loop from 2 to  num/2 ? Because prime number starts from 2 and any factor of a number  n  is ...

To Find Factorial Of A Number Using C Program

  Program 1: Factorial program in c using for loop #include <stdio.h> int main (){ int i , f = 1 , num ;   printf ( "Enter a number: " ); scanf ( "%d" ,& num );   for ( i = 1 ; i <= num ; i ++) f = f * i ;   printf ( "Factorial of %d is: %d" , num , f ); return 0 ; } Result Enter a number: 8 Factorial of 8 is: 40320 Program 2: Factorial program in c using pointers #include <stdio.h>   void findFactorial ( int , int *); int main (){ int i , factorial , num ;   printf ( "Enter a number: " ); scanf ( "%d" ,& num );   findFactorial ( num ,& factorial ); printf ( "Factorial of %d is: %d" , num ,* factorial );   return 0 ; }   void findFactorial ( int num , int * factorial ){ int i ;   * factorial = 1 ;   for ( i = 1 ; i <= num ; i ++) * factorial =* factorial * i ; } Result Enter a number: 8 Factorial of 8 is: 40320 Program 3: Factorial progra...

Questions of C Program

1. Write a C program to find the area of a circle. 2. Write a C program to find the area of a triangle. 3. Write a C program to swap two numbers without temp variable (or a third variable) 4. Write a C program to print ASCII value of the character 5. Write a C program to read a character in uppercase and then print in lowercase. 6. Write a C program to swap two numbers with temp variable 7. Write a C program to calculate the average of two number 8. Write a C program to calculate the simple interest. 9. Write a C program to find the quotient and remainder of two numbers 10.Write a C program that displays the size of every datatype. 1. Write a c program to add two integers and print the result ,inputs must be taken using scanf function. 2. Write a c program to add two float numbers without third variable and print the result ,inputs must be taken using scanf function. 3. Write a c program, to subtract two integers and print the result, inputs must be taken using scanf function. 4. Write...