C Langage Exercises
C Langage Exercises
bellow :
Input : 5.7*3
Output : =17.10
#include<stdio.h>
int main()
float first,second,result;
char operation;
scanf("%f%c%f",&first,&operation,&second);
switch(operation) {
case '+' :
result=first + second;
break;
case '-':
result=first - second;
break;
case '*' :
result=first * second;
break;
case '/':
result=first / second;
break;
default:
printf("Erreur!");
exit(1) ;
}
printf("=%.2f",result);
2-Write a code in C that find the square root of a number given with in the format of 0.000,
without using sqrt() function, but using a while loop:
Exemple :
#include<stdio.h>
int main()
float number,squareRoot=0;
printf("input a number:\t");
scanf("%f",&number);
while(squareRoot*squareRoot<number){
squareRoot+=0.00001;
printf("%.4f",squareRoot);
Exemple :
***
*
*
#include<stdio.h>
int main()
for(int y=30;y>=-30;y--){
for(float x=-4.2;x<=4.2;x+=0.2){
if(func>y-0.2&func<y+0.2){
printf("*");
printf("\n");
4-Write a code in C that find the number divisible by all the number between 1 to 10 :
#include<stdio.h>
int main()
int tr,x=0;
while(tr<10) {
tr=0;
x++;
tr++;
printf("%d",x);