Q9.
Write a C program to compute the 100th triangular number. A triangular number is obtained by
adding the integers from 1 up to 100.
[Hint:
main( )
{
int n, triangular_number;
triangular_number = 0;
for( n=1; n <=100; n = n + 1)
triangular_number = triangular_number + n;
printf(“The 100
th
triangular number is %d\n”, triangular_number);
}
].
Q10.
Modify the program in Q9 to generate the table of triangular numbers.
Q11.
Write a C program to find the GCD of two numbers, u and v.
[Hint:
/* say two numbers are u and v */
while ( v != 0)
{
temp = u % v;
u = v;
v = temp;
}
printf(“GCD is %d, u);
Do'stlaringiz bilan baham: