Saurashtra University Assistant Professor – 64 Posts
last date 18-05-2022
#include<stdio.h>
int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int n, i;
float sum = 0, x;
printf("Enter number of elements: ");
scanf("%d", &n);
printf("\n\n\nEnter %d elements\n\n", n);
for(i = 0; i < n; i++)
{
scanf("%f", &x);
sum += x;
}
printf("\n\n\nAverage of the entered numbers is = %f", (sum/n));
printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}
#include<stdio.h>
#include<math.h>
int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int n,sum,i,t,a;
printf("\n\n\nThe Armstrong numbers in between 1 to 500 are : \n\n\n");
for(i = 1; i <= 500; i++)
{
t = i; // as we need to retain the original number
sum = 0;
while(t != 0)
{
a = t%10;
sum += a*a*a;
t = t/10;
}
if(sum == i)
printf("\n\t\t\t%d", i);
}
printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}
#include<stdio.h> int main() { printf("\n\n\t\tStudytonight - Best place to learn\n\n\n"); int x; for(x = 0; x <= 10; x++) { if(x&1) // if number is odd printf("\t\t\t%d is odd\n",x); else if(!(x&1)) // ! is used inside if to reverse the boolean value printf("\t\t\t%d is even\n",x); } printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n"); return 0; }
| Numbers(1) | Numbers(2) | Numbers(3) | Numbers(4) | … |
real, dimension(5) :: numbers
integer, dimension (5,5) :: matrix
real, dimension(2:6) :: numbers
integer, dimension (-3:2,0:4) :: matrix
numbers(1) = 2.0
do i =1,5
numbers(i) = i * 2.0
end do
numbers = (/1.5, 3.2,4.5,0.9,7.2 /)
program divide implicit none integer :: x real :: y x = 1 y = x/3 print *, y end program divide
0.00000
y=x/3
x = 1
x = 10
3.00000
program check
!Integer and real arithmetic
implicit none
real :: x,y
integer i
x=2.0
i=2
y=x*((2**i)/3)
print *,y
y=x*((2.0**i)/3)
print *,y
end program check
program loop
implicit none
integer :: i
do i=0,20
print *,i
end do
end program loop
do i = 50,70,2
do i = 5,-5,-2
y = 1.0/x
z = xy
program xytab
implicit none
!constructs a table of z=x/y for values of x from 1 to 2 and
!y from 1 to 4 in steps of .5
real :: x, y, z
print *, ' x y z'
do x = 1,2
do y = 1,4,0.5
z = x/y
print *, x,y,z
end do
end do
end program xytab
x = 1.0
x = 1.0
x = x + 1.0
print *, x
x = x + 1.0
program increment
implicit none
integer :: i
real :: x
x = 1.0
do i=1,10
x = x + 1.0
print *, i,x
end do
end program increment
Head Constable (Ministerial) Apply Now Notification