Lab5 - Tao L in EE140 Lab#5/Lab#5 Question#1 Tao Lin/A...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Tao Lin EE140 Lab #5 //---------------------------------------------------------------- //Lab#5 Question#1 Tao Lin //A program that calculates and prints the sum of the even //integers from 2 to 30 //------------------------------------------------------------- #include <stdio.h> int main( void ) { int a,sum=0; //while a is less than or equal to 30,add a to sum for (a=2;a<=30;a+=2) sum+=a; printf( "The sum of the even integers from 2 to 30 is %d\n" ,sum); return 0; } RESULT: The sum of the even integers from 2 to 30 is 240 Press any key to continue . . .
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
//---------------------------------------------------------------- //Lab#5 Question#2 Tao Lin //A program that receive I and R value from users and calculate // and display V //------------------------------------------------------------- #include <stdio.h> int main( void ) { int R,I,V; //get R data printf( "Enter the R :" ); scanf( "%d" ,&R); //test if R is -1 or not while (R!=-1){ printf( "Enter the I :" ); scanf( "%d" ,&I); V=R*I; printf( "The V is: %d\n\n" ,V); //ask user for another R printf( "Enter the R :" ); scanf( "%d" ,&R); } return 0; } RESULT: Enter the R : 3 Enter the I : 5 The V is: 15 Enter the R : 9 Enter the I : 7 The V is: 63 Enter the R : -1 Press any key to continue . . .
Image of page 2
//-------------------------------------------------------------------------- //Lab#5 Question#3 Tao Lin //A program that ask users to enter 10 nonzero integers and find the minimum //------------------------------------------------------------------------- #include <stdio.h> int main( void ) { int a,min,count;
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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