C programming lanuage part- 2 - Techcomlite.blogspot.com

Latest

Stylish Time Display

Friday, April 21, 2023

C programming lanuage part- 2

   HOW TO WRITE A SIMPLE C PROGRAM

                   c programming language - Part 1 You learned the history of C and some of its basics. In this section I hope to explain to you how to write a simple c program.




Like other computer languages, C has several unique symbols. Without them, a c program cannot run correctly.Now let's learn about functions in c. The content is presented more simply and clearly so you can read more easily.


 Functions of c programming.

Here, it is difficult to present all the functions of C language to you. Because there are many functions in C language. However, some of them and their brief explanation are given below.


-printf(): used to print output to the console

-scanf(): used to read input from the console

-strlen(): used to find the length of a string

-strcpy(): used to copy one string to another

-strcmp(): used to compare two strings

-malloc(): used to allocate memory dynamically

-free(): used to deallocate memory

-exit(): used to terminate a program

-rand(): used to generate random numbers

-time(): used to get the current time

-strlen() - calculates the length of a string.

-strcat() - concatenates two strings.

-strcmp() - compares two strings.

-isalpha() - checks whether a given character is an alphabetic character.

-isdigit() - checks whether a given character is a digit.

-toupper() - converts a given character to uppercase.

-tolower() - converts a given character to lowercase.

-pow() - calculates the power of a given number.

-sqrt() - calculates the square root of a given number.

-rand() - generates a random number.

-time() - returns the current time in seconds.

-abs() - returns the absolute value of a given number.

-exit() - terminates the program.

-fopen() - opens a file for reading or writing.

-fclose() - closes a file.

-fprintf() - writes formatted output to a file.

-fscanf() - reads formatted input from a file.

-memset() - sets a block of memory to a specific value.

-memcpy() - copies a block of memory from one location to another.

-strstr() - searches a string for a substring.







 Now let's examine how to write a simple c program...


Here the header file should be entered first.


Eg- #include <stdio.h>

       #include<conio.h>

etc. can be seen in various ways.


As the second step, the main function should be added here.


Eg- void main()

       int main()

Here should be presented using parentheses.


Now study the following simple example. For that, you should go to codeblocks or an online c compiler application, paste this part there and check the functionality.

 #include<stdio.h>

int main()

{

    char name[100];


    printf("Enter your name here :");

    gets(name);


    printf("Your name is : %s", name);

    return 0;

}



OUTPUT


                                                    ask to enter the name :




Enter my name :





Final result :




              Thus, C program is unique among computer languages. It can also be seen how other languages ​​have been inspired in some way. However, you can get the most out of it by gaining a broad understanding of the C language. Especially when learning computer languages, learning C first will be helpful for learning other languages ​​like Java. Today you have the opportunity to learn this language for free by using the internet.


Another extension of this will be brought in the future.



Thank you.

Have a nice day..



Your code is : 772823TCL

1 comment:

  1. Thank you..please give me a post how to use arrays in c..❤️

    ReplyDelete

Ads