Program using switch statement to display : #include #include #include int main(){ char c; printf("Menu items are:\n A) EXCELLENT\n B)VERY \n C) VERY GOOD \n D) GOOD \n E) FAIL\n"); printf("Enter to show\n"); scanf("%c",&c); switch(c) { case 'A': printf("EXCELLENT"); break; case 'B': printf("V GOOD"); break; case 'C': printf("VERY GOOD"); break; case 'D': printf("GOOD"); break; case 'E': printf("FAIL"); break; default: printf("\ninput error"); getch(); } } QS no :3 #include #include int main() { int i,j; for(i=0;i<5;i++) { for(j=0;j<=i;j++) { if((i+j)%2==0) { printf("1\t"); } else printf("0\t"); } printf("\n"); } } OUTPUT: question 4: TO find the soln : ans= -11 #include #include #include int main(){ int x=2,n=5,sum=0,i; for(i=0;i QS 6: To find the sum of each rows of a 3*2 matrix: #include #include int main(){ int a[10][10],i,j; for(i=0;i<2;i++) { for(j=0;j<3;j++) { printf("enter the a[%d][%d] value:",i+1,j+1); scanf("%d",&a[i][j]); } } for(i=0;i<2;i++) { for(j=0;j<3;j++) { printf("%d\t",a[i][j]); } printf("\n"); } printf("............Sum..............\n"); for(i=0;i<2;i++) { int sum=0; for(j=0;j<3;j++) { sum= sum+ a[i][j]; } printf(" the sum of %d row is %d\n",i+1,sum); } }
Post a Comment