Thursday, January 1, 2015

loop(7)

1:
 #include <stdio.h>
///***counting 
 int main()   
 {  
     int n = 13;  
     int i;  
     for(i = 1; i <= 10; i++) {  
         printf("%d X %d = %d\n", n, i, n*i);  
     }  
     return 0;  
 }

output:
13 X 1 = 13
13 X 2 = 26
13 X 3 = 39
13 X 4 = 52
13 X 5 = 65
13 X 6 = 78
13 X 7 = 91
13 X 8 = 104
13 X 9 = 117
13 X 10 = 130

2:(other way)
 #include <stdio.h>
///***counting
 int main()
 {
     int n = 13;
     int i = 1;
     while (i <= 10) {
         printf("%d X %d = %d\n", n, i, n*i);
         i = i + 1;
     }
     return 0;
 }



output:
13 X 1 = 13
13 X 2 = 26
13 X 3 = 39
13 X 4 = 52
13 X 5 = 65
13 X 6 = 78
13 X 7 = 91
13 X 8 = 104
13 X 9 = 117
13 X 10 = 130

3:
#include <stdio.h>
///***calculating program:

int main()
{
int a,b,x;
printf("please enter three number:",a,b,x);
scanf("%d%d%d",&a,&b,&x);

   if(x==1){
    printf("The addition is:%d",a+b);
   }
  else if(x==2){
    printf("The substraction is:%d",a-b);
   }
   else if(x==3){
    printf("The division is:%d",a/b);
   }
    else if(x==4){
    printf("The multiplication is:%d",a*b);
   }
   else if(x==5){
    printf("The modulus number is:%d",a%b);
   }
   return 0;
}

output: depend on your value

No comments:

Post a Comment