Reply to comment
Mobile Robotics Workshop - 3rd Session
Tagged:
Its our third session in Mobile Robotics Workshop. Five problems were given to be programmed in C. Although I prefer GCC (Gnu compiler collection) than Turbo C, I dont have a choice. Its not my pc. Its Windows XP. Not Linux!!! Not GNU!!!
Here are the problems:
- Write a program to print the squares of numbers from 1 to 10, inclusive.
- Write a program to input 5 numbers and print their average.
- Write a program to input 5 numbers and print the largest value.
- Write a program to input numbers until the user enters 0, and then print the average of all the numbers, not including the 0.
- Write a program to show the Fibonacci numbers less than 100.
#include<stdio.h>
int main(){
int i;
for(i = 1; i <= 10; i++)
printf("%i ", i*i);
return 0;
}
#include<stdio.h>
int main(){
int n = 5;
int i;
float sum = 0;
float ave;
float x;
for(i = 0; i < n; i++){
printf("enter number %i: ", i+1);
scanf("%f", &x);
sum = sum + x;
}
ave = sum / n;
printf("average = %.2f", ave);
return 0;
}
#include<stdio.h>
int main(){
int i;
int n = 5;
float x;
float max;
printf("enter number 1: ");
scanf("%f", &max);
for(i = 1; i < n; i++){
printf("enter number %i: ", i+1);
scanf("%f", &x);
if( x > max)
max = x;
}
printf("maximum : %.2f", max);
return 0;
}
#include<stdio.h>
int main(){
int i = 0;
float x;
float ave;
float sum = 0;
do{
i++;
printf("enter number %i: ", i);
scanf("%f", &x);
sum += x;
}while( x != 0);
ave = sum / (i - 1);
printf("average = %.2f", ave);
return 0;
}
#include<stdio.h>
int main(){
int x = 0;
int y = 1;
int z = x + y;
while( z < 100 ){
z = x + y;
printf("%i ", y);
x = y;
y = z;
}
return 0;
} 
Recent comments
5 days 3 hours ago
2 weeks 4 days ago
3 weeks 1 hour ago
3 weeks 1 hour ago
4 weeks 2 days ago
4 weeks 5 days ago
4 weeks 5 days ago
6 weeks 1 day ago
7 weeks 3 days ago
7 weeks 3 days ago