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

Info iconThis preview shows pages 1–3. 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 . . .
Background image of page 1

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

View Full DocumentRight 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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online