Solved Assignment – MCS-011 Problem Solving and Programming of Q2

  JHARKHAND BOARD You are here

Q2. (a) Write a program to print this triangle:

 

               *

               ***

               *****

               *******

               *********

               ************

########## Code Start ############

#include(stdio.h)

#include(conio.h)

main()

{

int I,j;

for(i=1;i<=12;++i){

     printf(“%s

”,*);

     for(j=1;j<=I;++j)

     printf(“%s ”,*)

     }

}

########## Code End ##########

(b) Write a program to compute the average of the ten numbers 1, 4, 9, …, 81, 100 (i.e., the average of the squares of the numbers from 1 to 10). (2 X 10 = 20 Marks)

########## Code Start ############

#include(stdio.h)

#include(conio.h)

main()

{

int I;

float avg; sum=0;

for(i=1;i<=10;i++){

           sum=sum+(i*i);

         }

avg = sum/10;

printf(“

Average =%f”,avg);

}

Out put

Average= 38.5

########## Code End ##########

 

Assignment Index | <<Previous Answer | Next Answer>>