printfinvalid loop statements while entry controlled

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: ate statement associate statement associate statement Exit Next statement /* program to simulate a simple calculator */ #include<stdio.h> int main() { float a,b; float char opr; char printf("Enter number1 operator number2 : "); printf("Enter scanf("%f %c %f",&a,&opr,&b); switch(opr) switch(opr) default { case '+': case printf("Sum : %f",(a + b)); printf("Sum associate break; break; statement case '-': case printf("Difference : %f",(a - b)); printf("Difference break; break; case '*': case printf("Product : %f",(a * b)); printf("Product break; break; case '/': case printf("Quotient : %f",(a / b)); printf("Quotient break; break; default: default: printf("Invalid Operation!"); printf("Invalid } } Loop Statements while – (Entry controlled ) Entry Test Condition ? true do-while – (Exit controlled ) Entry False Body of The loop Following Statement /* sum of 1 to 10 numbers */ #include<stdio.h> int main() { int i = 1,sum = 0; int while(i<=10){ while(i<=10){ sum = sum + i; sum i = i + 1; 1; } pri...
View Full Document

Ask a homework question - tutors are online