Study and Explore Coding Opportunities with C/C++ Basics

Page 1

5 Reasons Why You Should Opt Your Career As Quality Tester


Learn Basics Of C/C++ And Explore Coding Opportunities The era we live in today is a technological era. Technology is everywhere around us from a smartphone in our hands to the automotive cars that we use to travel. But the only question here is that how do these things work without any kind of human efforts? The answer is programming. All these things are programmed to perform certain types of tasks in a specific manner. Our future lies in programming, therefore, learning to be an expert in any programming language will be very much beneficial. But to be a professional, from where we should start? The answer to this question lies in C and C++. They are the most common and known languages today. Each and every programmer started with C and C++ and then proceeded to other high-level languages. Therefore, further in this article, we will learn the basics of C and C++. Basics of C: C is a general-purpose and imperative computer programming language that was designed by Dennis Ritchie at Bell Labs in 1972. Here are some basics of C language. •

Example C Program: #include int main() { /*_some_comments_*/ Printf (“Hello_World!“); getch(); return 0; }


Learn Basics Of C/C++ And Explore Coding Opportunities •

Syntax of the program: The syntax of the program is following by the exact numbering that is been given to the above program. #include: 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;:This command terminates C program (main function) and returns 0. }: This indicates the end of the main function.

Basics of C++: C++ is a general-purpose object-oriented programming (OOP) language, developed by Bjarne Stroustrup, and is an extension of the C language. Here are some basics of C++ language.


Learn Basics Of C/C++ And Explore Coding Opportunities •

Example Program: #include using namespace std; int main() { cout << "Hello this is C++"; }

The syntax of the program: ◦ Header files are included at the beginning just like in C program. Here iostream is a header file which provides us with input & output streams. Header files contained predeclared function libraries, which can be used by users for their ease.

◦ Using namespace std, tells the compiler to use the standard namespace.

Namespace collects identifiers used for class, object and variables. The namespace can be used by two ways in a program, either by the use of using statement at the beginning, like we did in the above-mentioned program or by using the name of the namespace as a prefix before the identifier with scope resolution (::) operator.


Learn Basics Of C/C++ And Explore Coding Opportunities Example: std::cout << "A"; ◦ main(), is the function which holds the executing part of the program its return

type is int.

◦ cout <<, is used to print anything on the screen, same as printf in C language.

◦ cin and cout are same as scanf and printf, the only difference is that you do not

need to mention format specifiers like %d for int etc, in cout & cin.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.