Posts

Showing posts from January, 2023
 #include<stdio.h> int main() { int i,j; char patt[]="HELLO"; for(i=1;i<=5;i++) {  for(j=0;j<=i-1;j++)  {  printf("%c",patt[j]);  }  printf("\n");  } for(i=3;i>=0;i--) {  for(j=0;j<=i;j++)  {  printf("%c" ,patt[j]);  }  printf("\n"); } } 
Image
 1) Write a program to calculate the perimeter of a rectangle. Take sides, a & b, from the user.      Answer:- C Programming code                                   - : CODE:- //Write a program to calculate the perimeter of a rectangle  #include<stdio.h> int main() {     int a, b, perimeter;     printf("enter the side of rectangle a:\n",a);     scanf("%d",&a);     printf("enter the side of rectangle b:\n",b);     scanf("%d",&b);     perimeter=2*(a+b);     printf("perimeter of rectangle is : %d",perimeter);     return(0); } Input and output :-