logo

Crowdly

Browser

Додати до Chrome

Coding Café

Шукаєте відповіді та рішення тестів для Coding Café ? Перегляньте нашу велику колекцію перевірених відповідей для Coding Café в dle.plaksha.edu.in.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

What would happen if the following piece of code was compiled?

#include <stdio.h>
int main()

{

        int a,b,c;

        scanf("%d",&a);

        scanf("%d",&b);

        float c = a+b;

        printf("%f\n",c);

        return 0;

}

Переглянути це питання
A compiler is a software that works on machine level code to produce an executable file.
0%
100%
Переглянути це питання

Write a C program that reads four

integers and displays the pair with the largest sum. For example, if the

user enters 10, -8, 17 and 5, the program

should display

10 + 17 = 27

. First, you write

out all possible approaches to solving this problem and then use one of them to

write your code.

Переглянути це питання

There are two statements associated with

loops - break and continue. When a break

is encountered inside a loop, program control is transferred outside of it. So,

you use a break within a loop when you want to stop the loop execution at that

instant.

For instance, let’s

suppose you want to find out and print the first occurring multiple of 19

between two given numbers n1 and n2. Here’s what you will do:

int found = 0;  /* a flag to indicate whether multiple found

or not */

for (i=n1; i<=n2; ++i)

  if (i % 19 == 0){

        found=1;    /* setting flag to 1 */

        break;      /* multiple of 19 found; don’t look further */

  }

  if (found)

   printf("%d is the first multiple of 19 between %d and %d.\n", i, n1, n2);

 else 

printf("There is no multiple of 19 between %d and %d.\n", n1,n2);

Now, with this

information, write a C program to find out and print if a given number is prime

or not. Incorporate an input validation check to make sure that the input is

valid.

Переглянути це питання

Rewrite the following for loop as a

while loop (make sure to include the rest of the required

preceding code):

for(x = 1; x < 10; x++)

{

   printf("%d", x);

}

and the following

while loop as a for loop:

a = 1;

b = 6;

while (a < b)

{  

a++;  

printf("%d\n", a);

}

Переглянути це питання

You can find the declarations of

mathematical functions in the header file

<math.h> that you must #include in your program just as you do <stdio.h>. For instance, to use

a function such as pow(),

to get the square of x and

store the result in y,

you will write the following C code:

int

x, y;

x = pow(x, 2);

Now

try to compile the file q5.c as

usual. Do you get an error message that says, "Undefined

reference to pow"? Since we have a math feature in our

program, we need to compile the program slightly differently.

    $gcc q3.c –lm

The

option

–lm

helps in linking the

math library to your program.

Using

this information, write a C program that reads a positive integer and displays

the largest positive integer N for

which the sum 1

2 + 22

+ 3

2 + … + N2

is less than the given

number. The sum should be displayed too. Include

break and continue statements

at appropriate places. Also, remember to include suitable input validation

checks.

Переглянути це питання

Write a program that prints a

Fahrenheit-to-Celsius conversion table from 0 C to 100 deg. C at intervals of

10 deg. C. The table should appear in the format shown below:

  0 degrees F =  -17 degrees C

 10 degrees F =  -12 degrees C

...

...

100 degrees F =  

37 degrees C

Переглянути це питання

Recall the question from last week’s

lab exercise to print the difference between itself and its reverse. Modify

your solution to work for any n-digit number taken as input, using a while loop.

Переглянути це питання

The continue statement must be associated

with a loop. When encountered, program control jumps to the end of the loop

iteration, disregarding the rest of the loop body. For instance, let’s suppose

you want to

exclude

printing all multiples of 19 between two given

numbers n1 and n2. Shown below is an excerpt. Please write the entire C

program.

for (i=n1; i<=n2; ++i) { 

   if (i % 19 == 0)

continue;  /* the remainder of the loop body is skipped */

printf("%d\n", i);

}

Переглянути це питання

Write a C program that takes a string input from the user and shifts each character forward by one using pointer arithmetic. For instance, the string "Hello" should be changed to "Ifmmp"

Convert this program into a function called encode(char arr[]) and implement another function called decode(char arr[]) to shift each character of a string back by one. 

char str[] = "Hello";

encode(str); /* str changed to "Iffmp" */

decode(str); /* str changed to "Hello" */

Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на dle.plaksha.edu.in?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome