CIS 1500 Lecture Notes - Lecture 4: C Mathematical Functions, Modulo Operation, Random Number Generation

36 views4 pages

Document Summary

You can"t see this unless you"ve shared :: #sharingiscaring. Questions before lecture: a b" grade is an exceptional understanding of course content", learn and understand your materials. Overview: strings: math functions, integer mathematics and type conversions, integer overflow, random numbers. This can lead to performance issues long long num = 0; scanf( %ll , &num); printf( %ll , &num); Math functions: include tons of math functions in your c program by: This will assign 411 to avg avg = (double)(sum/3); // casting as double this will return 411. 333333 :) #include if you"re curious about how pseudo-random" number generation works, google the algorithm. Random number generation is produced by: double random = rand(); // produces random num between 0 and rand_max. This is not very useful, so use the modulo function to get remainder from division of rand() to specify a random number between some range of values. The modulo operator (%) gives you the remainder after a division.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents