Reload your browser or click the button below to continue.
Disable AdBlock Plus:
Click on the icon in yor browser toolbar.
Click the blue button next to "Block Ads On:"
Click the red "Refresh" button or click the button below to continue.
Disable Adguard AdBlocker:
Click on the icon in yor browser toolbar.
Click on the toggle next to "Protection on this website".
Reload your browser or click the button below to continue.
Disable uBlock Origin:
Click on the icon in yor browser toolbar.
Click on the big blue "power" icon.
Reload your browser or click the button below to continue.
Alternative structure exercises in C Programming in C
Even or odd: Write a program that reads an integer value x and displays whether x is an even or an odd number....
Maximum of 3 integers: Write a program that reads three integer values (A, B, and C) from the keyboard and displays the larger of the three values, using
if - else and a MAX help variable.
if - else if - ... - else without help variable
conditional operators and a MAX h...
Sort 3 integers: Write a program that reads three integer values (A, B and C) on the keyboard. Sort the values A, B and C by successive exchanges so as to obtain: val (A) $$\leq$$ val (B) $$\leq$$ val (C)....
Display the addition sign of 2 integers without performing the sum: Write a program that reads two integer values (A and B) from the keyboard and displays the sign of the sum of A and B without performing the addition.
Use the fabs function from the <math.h> library....
Real solutions of a second degree equation: Write a program that calculates the real solutions of a second degree equation \(ax^2+bx+c=0\) by discussing the formula: \(x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}\)
Use a help variable D for the discriminant value \(b^2-4ac\) and decide using D if th...
Electricity bill: Write a program that asks a customer to enter the number of consumed electricity units. The program then calculates and prints the electricity bill without VAT, and then prints it with VAT knowing that:
For the first 50 consumed units, the customer p...
Biggest of two numbers: Write a program that reads and prints the biggest of 2 numbers....
Check divisibility by 2 and 3: Write a program that, given the integer n=13251, displays the value:0 if n is not divisible by 2 or by 31 if n is divisible by 2 and not by 32 if n is divisible by 3 and not by 23 if n is divisible by 2 and by 3...
Category of a number: Write a program that reads a real number X and displays its category:
Category A if (0 < = X < 37)
Category B otherwise
...
Lucky numbers: A four-digit number ABCD is called Lucky if $$A + B = C + D$$.
Write a program that asks the user to enter a four-digit number n and prints whether n is a Lucky number or not.
Example:
The number 3719 is a Lucky number since 3 + 7 = 1 + 9
The number ...
Integers manipulation: Write a program that reads two integers $$X$$ and $$Y$$, and does the following:
$$X$$ takes the value of $$Y$$ if ($$X \leq Y$$ or $$Y$$ is a divisor of $$X$$)
$$Y$$ takes the value of $$X$$ if ($$X \geq 30$$ and $$Y$$ is a multiple of $$X$$)
...
Result of a division: Write a C program that reads three integers a, b and c, and displays on the screen the result of the expression $$\frac{ab}{c}$$ if c is not null. Your program displays the message 'Wrong value of c' if c null.
Execution example:
Enter three numbers ...
Solution of a system: Write a program that reads six real values a, b, c, u, v, w and then displays the solution of the following equations:$$a*X + b*Y + c = 0$$$$u*X + v*Y + w = 0$$...
Calculus of an expression: Write a program that reads two positive integer values X and Y. The program must then calculate and display the result of the following expression :
\(\frac{(X^2+1)(\frac{X}{Y}-3)}{(X-Y^2)(Y^2-X)}\)...
Derivative approximation: Let the mathematical function f be defined by $$f(x) = (2x + 3)(3x^2 + 2)$$
Write a program C that calculates the image by f of a number entered on the keyboard.
An approximation of the derivative f' of the function f is given at each point x, for h ...
Tens and hundreds of a number: Write a program that displays the digit of the tens of a number entered on the keyboard. Same question for the hundreds....
Closest value to the average: Write a program that reads 3 integers number on the keyboard without telling the user to enter the values and then displays on the screen the value of the closest integer to their average and then go to a new line....
ATM money withdrawal: Knowing that ATMs should withdraw the minimum number of notes for each withdrawal, write a program that reads an amount of money in LL on the keyboard without telling the user to enter the value and then displays on the screen the minumum numbers of ...
KM conversion: Seeing that 1 mile is equal to 1609 meters or 1760 yards, and that 1 yard is equal to 3feet and that 1 foot is equal to 12 inches, write a program that reads a real number of kilometers and converts it to miles, yards, feets (all 3 in integer) and in...
Program output: Give the output on the screen of the following program (indicate a space using this symbol _):
#include<stdio.h>double mystery(int A[], int i){ i = A[i] * 2; A[0] = 0; return i+1;}
int main(){ int i = 8, j = 5, k, A[...
Cost of a telephone call: Write a program that asks the user to enter a number of minutes and a number of seconds, then calculates and displays the cost of a telephone call according to the following rules:
a unit is equal to 20 seconds;
the first minute is indivisible and is...
Program output 5: Give the output on the screen of the following program
#include <stdio.h>int main(){ int x , y ,z; x = y = z = 1; x += y += z; printf("%d\n", x < y ? y : x); printf("%d\n",x < y ? x++:y++)...
Program output 6: Give the output on the screen of the following program
#include <stdio.h>void print(int x, int y, int z){ printf("x = %d \t y = %d \t z = %d\n", x ,y ,z);}int main(){ int x , y ,z; x = y = z = 1; ++x || ++y &...
Program output 12: Give the output on the screen of the following program (indicate a space using this symbol _):
#include<stdio.h>int main(){ int a = 7, b = 4, c; double x = 0.02, y = -0.05, z = 0.1 ; printf("#1# %d ##\n", (a + b) % 1234); ...
Program output 13: Give the output on the screen of the following program (indicate a space using this symbol _):
#include<stdio.h>double mystery(int T[], int i){ int k; for(k=0 ; k<i ; k++) T[k] -= T[i] - k; return T[k] + ...
Array manipulation using functions: Write the function $\texttt{int READDIM()}$ that reads and returns a strictly positive integer $N$ less than 50;
Write the function $\texttt{void READARRAY(int T[], int N)}$ that fills $N$ positive integers in the array $\texttt{T}$;
Write the functi...
Program output 10: Give the output on the screen of the following program
#include <stdio.h>
#define PRINT(format,x) printf(#x " = %"#format"\t",x)#define NL putchar('\n');
#define PRINT1(f,x) PRINT(f,x);NL#define PRINT2(f,x1,x2) PRINT(f,x1);PRINT1(f,x2)#define...