Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What are the outputs of the following C statements? For some, you may need to input (a) i = 1; while (i 0); (c) int

What are the outputs of the following C statements? For some, you may need to input

(a) i = 1;

while (i <= 64)

{

printf("%d ", i);

i *= 2;

}

(b) i = 9384;

do {

printf("%d ", i);

i /= 10;

} while (i > 0);

(c) int i;

for (i = 10; i >= 1; i /= 2)

printf("%d ", i++);

(d) int a[3] = {1, 2, 3};

int b[3];

b = a; // What is the effect of this statement? If an error,

// explain why.

(f) int index = 1;

while (index++ < 4)

{

printf("Value of expression is: %d ", 2 * index + 2);

}

(g) #include

#define FORMAT "%s! C is cool! "

int main( )

{

printf(FORMAT, FORMAT);

return ;

}

(h) int x = 0;

while (++x < 3)

printf("%4d", x);

(i) #include

int main( )

{

int i = 0;

while (++i < 4)

printf("Hi! ");

do {

printf("Bye! ");

} while (i++ < 7);

puts(" ");

return 0;

}

(j) char ch;

for (ch = 'a'; ch <= 'd'; ch++)

printf("The ASCII value for %c is %d ", ch, ch);

(k) #include

int main( )

{

int i = 0;

while (i < 3)

{

switch(i++)

{

case 0 : printf("cat ");

case 1 : printf("hat ");

case 2 : printf("rat ");

default: printf("Oh no!);

}

puts(" ");

}

return 0;

}

(l) #include

int fun1(int n);

int main( )

{

int num;

printf("Enter a positive integer: ");

scanf("%d", &num);

printf("Value returned = %d ", fun1(num));

return 0;

}

int fun1(int n)

{

if (n != 0)

return n + fun1(n-1);

else

return n;

}

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

Students also viewed these Databases questions

Question

Which personal relationships influenced you the most?

Answered: 1 week ago

Question

What were your most important educational experiences?

Answered: 1 week ago