Found 7197 Articles for C++

How to print out the contents of a vector in C++?

Chandu yadav
Updated on 14-Feb-2025 18:05:07

35K+ Views

Vectors are similar to the dynamic arrays but vectors can resize. They are sequence containers that can change their size according to the insertion or deletion of elements. Containers are the objects which holds the data of same type. Vectors may allocate some extra storage for the future growth of elements in the vector. Its elements are stored in the contiguous memory. The data is entered at the end of vector. In this article, we will show you how to print the contents of a vector in C++. Example Scenario: std::vector vec = {10, 20, 30, 40, 50}; You ... Read More

Do you think operator < is faster than <= in C/C++?

Arjun Thakur
Updated on 25-Jun-2020 09:45:25

1K+ Views

No, the operator < takes same time to execute as operator

List of C++ IDEs for Linux

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

409 Views

The following are some of C++ IDEs for linux − Eclipse Galileo with CDT Plugin Eclipse is a well-known open source and cross platform IDE. It provides full functional C/C++ IDE with the following features − Code editor with support for syntax highlighting Support for folding and hyperlink navigation Source code refactoring plus code generation Tools for visual debugging such as memory, registers etc. NetBeans IDE NetBeans is free, open source and popular IDE for C/C++. These are some of its features − Support for automatic packaging of compiled application into .tar, .zip and many more archive ... Read More

What is the difference between printf() and cout in C++?

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:01:01

3K+ Views

Both printf() and Cout are used to display the output format in C and C++ respectively. Each function has its syntax and characteristics that are based on user needs and preferences. In this article, we will learn the difference between print () and cout in a detailed manner. What is printf() in C? The printf() function is mainly used in C language. It is a formatting function that prints to the standard out. It prints to the console and takes a format specifier to print. It returns an integer value. It is not type-safe in input parameters. It can be ... Read More

How do I convert a char to an int in C and C++?

Tapas Kumar Ghosh
Updated on 04-Jun-2025 14:12:57

25K+ Views

In C/C++, char represents a single character, whereas int is an integer that can store both positive and negative values, but not fractional or decimal values. If you are given a character and want to convert it into an integer, it is easy and can be achieved with the different approaches. In this article, we will learn how we can convert a given character to an integer with different approaches. The following are some of the ways to convert a character to an integer: Using sscanf() Function Using atoi() Function ... Read More

#pragma Directive in C/C++

Ankith Reddy
Updated on 25-Jun-2020 09:50:00

3K+ Views

The preprocessor directive #pragma is used to provide the additional information to the compiler in C/C++ language. This is used by the compiler to provide some special features.Here is the syntax of #pragma directive in C/C++ language, #pragma token_nameThe table of some of #pragma directives in C/C++ language is given as follows, Sr.No.#pragma Directives & Description1#pragma startupBefore the execution of main(), the function specified in pragma is needed to run.2#pragma exitBefore the end of program, the function specified in pragma is needed to run.3#pragma warnUsed to hide the warning messages.4#pragma GCC dependencyChecks the dates of current and other file. If ... Read More

Pass an array by value in C

Tapas Kumar Ghosh
Updated on 05-May-2025 18:36:54

901 Views

In C programming, when you pass an array by value, you are not sending the entire array. Instead of this, it passes a pointer to the first element. So, this shows functions directly work with an original array but do not copy. Note: If we make any changes to the array element, those changes will be reflected in the original array outside the function as well. Syntax There are two syntaxes for passing an array by value as follows: i. The syntax of array notation for passing array to function. void function_name(data_type array_name[], int size) { // Function ... Read More

Reverse a string in C/C++

Tapas Kumar Ghosh
Updated on 21-May-2025 18:03:29

2K+ Views

There can be multiple ways to reverse a string in C and C++. In this article, we will learn reversing a string using different approaches with the appropriate examples. Consider the below example with input and output scenarios: Input // characters representation from left to right inp = "Tutorialspoint" Output // characters representation from right to left out = tniopslairotuT Now, we have following approaches to solve the reverse of a given approach: Using Two Pointer Using reverse() Function Using strlen() Function Reverse String ... Read More

Character arithmetic in C

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:06:05

5K+ Views

In C, character arithmetic is defined by char data type. This is used to implement arithmetic operations like addition and subtraction on characters in C language. It is used to manipulate the strings. When the characters are used with the arithmetic operations, it converts them into integer value automatically i.e. ASCII value of characters. Understanding Characters Represention To understand the character represented using char data type then learn the ASCII value (integer) of each character. Some values are provided for the references such as, 'A' has an ASCII value of 65 'B' has an ASCII value of 66 'a' has ... Read More

C Program for LowerCase to UpperCase and vice-versa

Ankith Reddy
Updated on 02-Sep-2023 13:20:59

82K+ Views

Here is the program to convert a string to uppercase in C language,Example Live Demo#include #include int main() {    char s[100];    int i;    printf("Enter a string : ");    gets(s);    for (i = 0; s[i]!='\0'; i++) {       if(s[i] >= 'a' && s[i] = 'a' && s[i] = 'A' && s[i] = 'A' && s[i]

Advertisements