53019.docx - #define_CRT_SECURE_NO_WARNINGS#include <stdio.h>/Main int main(void/Remember that a number can't go before the letter when naming ints int

53019.docx - #define_CRT_SECURE_NO_WARNINGS#include...

This preview shows page 1 - 4 out of 4 pages.

#define_CRT_SECURE_NO_WARNINGS #include <stdio.h> //Main int main(void) { //Remember that a number can't go before the letter when naming ints int a1=3, a2=4, a3=a1/a2, a4; double b = a1/a2; double b1, b2; //Variable declarations for V4 //Display //Version 1 (use all results, Wrong result for ratio) printf("a1=%d a2=%d a3=%d\n", a1, a2, a3); //Version 2 use inegers for the first two variables and double for third (wrong result for ratio as well) printf("a1=%d a2=%d double b=%lf\n", a1, a2, b); //Version using typecast (correct result) b = ((double) a)/((double)b); printf("a1=%d a2=%d double b=%.1lf\n", a1, a2, b); //Version using double throughout (correct result as well)
Image of page 1

Subscribe to view the full document.

b1= 3; b2 =4; b = b1 / b2; printf(“b1=%.2lf b2=%.2lf double b=%.2lf\n”, b1, b2, b); //Second part of activity 5 printf(“Please enter two integers: “); //either sequentially scanf(“%d”, &a1); scanf(“%d”, &a2); //or one command Scanf(“%d%d”, &a1, &a2); /*Here user needs to use a whitespace character (e.g) return to separate the values*/
Image of page 2
Image of page 3

Subscribe to view the full document.

Image of page 4
  • Spring '10
  • TAMIWSORGENTE
  • Division, Zagreb, double b

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes