Sunteți pe pagina 1din 8

5 "

037027190 ..
036857027 ..

.1

.2
:1

#include
#include
#include
#include

<stdio.h>
<stdlib.h>
<conio.h>
<limits.h>

void main () {
int num ,sum=0 ,i=0 ,max1=0 ,max2=INT_MIN;
float ave;
printf("Insert your nums, end with 0\n"); //input numbers
scanf_s("%d" , &num);
while (num)
{ i++ ; //counter
sum += num; //add the num to sum (for the average cakculation)
if ( max1<num )
{ max2 = max1; //max 2 will get the 2nd maximum num
max1 = num; }
if (max2 < num && max1 > num) //making sure max2 will have the
2nd maximum num
max2 = num;
scanf_s("%d" ,&num); //input the next num
}
ave = (float)sum / i ; //calculating average
printf("Sum = %d , Ave = %.2f , 2nd max = %d" , sum ,ave ,max2); //print
the results
_getch();
return;
}

:2
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
int x,y,i,m,z;
printf("Insert a number within [1,1100]: ");
scanf_s("%d",&x);
if(x==0) { getch(); return 0; } //the program will be stopped if
the number is 0
if ( (x<0) || (x>1100) ) { //if the number isn't between 1 till
1100
printf("illigal number- insert a number within [1,1100]: ");
scanf_s("%d",&x); }
if (x>6)
for (i=0 ; i<=15 ; i++) {
y = x-5+i ; // 5th number under input number till
10th above in loop
do{
m = y%10; //chacking if number's digit is 7
z = y/10; //minimize the number for chacking
the next digit
y = z; //making sure that 'm' will get the
new value of y
if (m==7) break; // if digit is 7 get out of
the loop and continue the program
}
while (y!=0); //the loop will be continued till the
number will be minimized to 0
if((m==7)||((x-5+i)%7==0)) printf ("\nboom\n");// if
number is divided in 7 or has the digit 7 the output will
be "boom"
else printf ("%d ",x-5+i); } // if not divided in 7 and
has not the digit 7 the out put will be the value's number
if (x<=6)
for (i=0 ; i<(10+x) ; i++) {
y=1; //primer number under input number is 1 till 10th
number above in loop
do{
m=y%10;
z=y/10;
y=z;
if (m==7) break; }
while (y!=0);
if((m==7)||((1+i)%7==0)) printf ("\nboom\n");
else printf ("%d ",1+i);}
_getch();
return 0;
}

#include
#include
#include
#include

<stdio.h>
<stdlib.h>
<conio.h>
<math.h>

:3

void main () {
int a ,b ,c ;
for (c=5 ; c<=50 ; c++) //checking c untill 50
{
for(a=1 ; a<c ; a++) //check a
{
for (b=a ; b<c ; b++) //check b (making sure the nums wont
repeat them selfs)
{
if ( (a*a) + (b*b) == (c*c) ) { //calculating Pitagoras
existence
printf("%d %d %d \n" ,a, b, c ); //output the
nums
break ; }
}
}
}
_getch();
return;
}

:4
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void main () {
int n; //input num
int str1, str2 ,spc, r=1, x; //start, space , row number ,space times
printf("Please insert a number for your drowing: "); //input a number
scanf_s("%d" ,&n);
for (r=0 ; r<n ; r++) //row
{ for (str1=0 ; str1 < (r+1) ; str1++) putch('*'); //print stars
for (spc=0 ; spc < (2*n-2*(r+1)) ; spc++) putch(' '); //print
spaces
for (str2=0 ; str2 < (r+1) ; str2++) putch('*'); //print stars
printf("\n"); //pass to next row
}
_getch();
return;
}

:5
#include
#include
#include
#include

<stdio.h>
<stdlib.h>
<conio.h>
<math.h>

void main () {
int i ,num ,dig=0 ,sum ,x=0 ;
for (i=100 ; i<=999 ; i++) //3 digits num- enter the loop
{
num = i ;
while (num)
{ dig = num%10 ; //to get the digit
num /= 10; //to get to the next digit after the loop
x = x * 10 + dig; //will get the oposite number
}
sum = abs(i-x); //sum the absolute value
x=0;
if (sum%99!=0) //check if the number divides in 99
{ printf("The argument is not correct, the number that shows
that is %d\n" ,i);
return; }
}

printf("The argument is correct!"); //if all the absolute numbers


divided in 99- argiment correct

_getch();
return;
}

-6:
res
1
2
4
16
256
65536
131072
262144
524288
1048575
2097152
End the loop

Index
0
1
2
3
4
5
6
7
8
9
10

:
.1
Index = 10 , res = 2097152
" " . Autos
.2
" F10
.3
.
:
.4