Why we use srand() function in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why we use srand() function in c++

to print the random numbers we use rand() function but what role be done bye srand() function

25th Mar 2018, 7:10 PM
Mayur Warpe
Mayur Warpe - avatar
10 Answers
+ 2
Most welcome bro 💙 good luck 💚
25th Mar 2018, 7:36 PM
Baraa AB
Baraa AB - avatar
+ 6
The srand() function in C++ seeds the pseudo random number generator used by the rand() function. The seed for rand() function is 1 by default. It means that if no srand() is called before rand(), the rand() function behaves as if it was seeded with srand(1). FOR MORE: https://www.programiz.com/cpp-programming/library-function/cstdlib/srand
25th Mar 2018, 7:17 PM
Baraa AB
Baraa AB - avatar
+ 5
No of course here are some difference: Swift is used for iOS Apps and Java is not. Java is a compiled language and Swift is not. Java can be used for a variety of things and developing Android apps is one of them. Computed Properties: Conventionally we create getter and setter for member variables in a class and separate methods to return any computation over them. In swift same is accomplished with computed properties however conventional way still exists. Structures are passed by value : In Java there is no concept of structures and in c++ structure and classes are same except structure’s member variables are public by default. In swift structures are passed by value not reference. This difference requires a separate annotation for structures to differentiate it. No Abstract classes: Swift does not have concept of abstract classes. An abstract class is a class which provide partial implementation. It does not have to implement all methods declared. Abstract classes are powerful concept to put common code in one place for multiple derived classes from same base class. Global functions: swift can have global functions (i.e. without class scope) which is not possible in Java but possible in C++.
25th Mar 2018, 7:33 PM
Baraa AB
Baraa AB - avatar
+ 4
https://www.sololearn.com/learn/CPlusPlus/1638/?ref=app Check this lesson.. Complete it all..
25th Mar 2018, 7:22 PM
Baraa AB
Baraa AB - avatar
+ 2
Nice to hear that.. Good luck 💚
25th Mar 2018, 7:25 PM
Baraa AB
Baraa AB - avatar
+ 1
understood but little
25th Mar 2018, 7:19 PM
Mayur Warpe
Mayur Warpe - avatar
+ 1
ok completely understood thank u so much
25th Mar 2018, 7:23 PM
Mayur Warpe
Mayur Warpe - avatar
+ 1
one thing can I ask u
25th Mar 2018, 7:26 PM
Mayur Warpe
Mayur Warpe - avatar
+ 1
got it ... thank you
25th Mar 2018, 7:36 PM
Mayur Warpe
Mayur Warpe - avatar
0
are the swift and java are same
25th Mar 2018, 7:28 PM
Mayur Warpe
Mayur Warpe - avatar