2020 - c program with parth patthar

c program with parth patthar

learn c and c++ in better way and with simple example.

Believe on your own logic

Tuesday, October 13, 2020

What is the difference between C and C plus plus programming language ?

October 13, 2020 0
What is the difference between C and C plus plus programming language ?
Sr. No.KeyCC++
1IntroductionC was developed by Dennis Ritchie in around 1969 at AT&T Bell Labs.C++ was developed by Bjarne Stroustrup in 1979.
2Language TypeAs mentioned before C is procedural programming.On the other hand, C++ supports both procedural and object-oriented programming paradigms.
3OOPs feature SupportAs C does not support the OOPs concept so it has no support for polymorphism, encapsulation, and inheritance.C++ has support for polymorphism, encapsulation, and inheritance as it is being an object-oriented programming language
4Data SecurityAs C does not support encapsulation so data behave as a free entity and can be manipulated by outside code.On another hand in the case of C++ encapsulation hides the data to ensure that data structures and operators are used as intended.
5Driven typeC in general known as function-driven language.On the other hand, C++ is known as object driven language.
6Feature supportedC does not support function and operator overloading also do not have namespace feature and reference variable functionality.On the other hand, C++ supports both function and operator overloading also have namespace feature and reference variable functionality.

C++ program to check if a given string is valid integer

October 13, 2020 0
C++ program to check if a given string is valid integer

 

#include <iostream>

using namespace std;

bool isNumber(string s)

{

for (int i = 0; i < s.length(); i++)

if (isdigit(s[i]) == false)

return false;


return true;

}


// Driver code

int main()

{

// Saving the input in a string

string str = "6790";


// Function returns 1 if all elements

// are in range '0-9'

if (isNumber(str))

cout << "Integer";


// Function returns 0 if the input is

// not an integer

else

cout << "String";

}