Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (Variable Type) It is very important to use the correct type (int, float, char, double) for each variable defined/declared. If you mix different types

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1. (Variable Type) It is very important to use the correct type (int, float, char, double) for each variable defined/declared. If you mix different types of variables, the precedence is double > float > int=char. Compose the following program and run it. Discuss (a) the result (why it did not work as expected) and (b) how you can modify the code so that it prints the expected value. #include int main() int a-10, b=20; float c; c=a/b; printf ("Answer = %f ", c); return 0; 2. (If statement) The syntax of the if statement is: if (.....) {statement 1; statement 2; statement 3; } else statement4; Note that if you want to execute multiple statements after if you have to enclose them by { and } else is optional above. Write a program to tell whether an integer entered from the keyboard is an even number or an odd number. Use the following as a template: #include int main() int a; printf ("Enter an integer ="); scanf("%d", &a); if (aX3==0) printf("The number you entered is a multiple of 3. "); else printf("The number you entered is NOT a multiple of 3. "); return 0; Note: afm returns the remainder of a divided by m. 4. It is possible to approximate the sum of an infinite series by using the for statement. The following code computes which converges to 2. (proof). (mathjoke). Here is a code to do the above. #include #include int main() int i, n; float sum=0; printf("Enter # of terms ="); scanf("%d", &n); for (i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

5. We have often heard caregivers tell their children?

Answered: 1 week ago

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago