1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <stdio.h>
int main()
{
int i, num, choice;
printf("1,2,3,4 ? ");
scanf("%i", & choice);
EnteringChoice(){
printf("enter a number: ");
scanf("%i", & num);
}
if (choice == 1){
printf("counting forward from 1 to %i", num);
for (i=0 ; i <= num; i++)
printf("\n %i", i);
}
if (choice == 2){
printf("counting backwards from %i to 1", num);
for (i=0 ; i <= num; i++)
printf("\n %i", i);
}
if (choice == 3){
printf("Displaying odd numbers from 1 to %i", num);
}
if (choice == 4){
printf("Displaying even numbers from 1 to %i", num);
} |
Partager