Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

mar 24 problems

 

Program 1:


#include <stdio.h>
int main() 
int a; 
scanf("%d",&a);
 switch(a) 
{
case 7: 
printf("0"); 
break; 
case 2: 
printf("8"); 
break; 
case 5:
 printf("3"); 
break; 
case 3: 
printf("10"); 
break; 
return 0;
}

Program 2:

#include<stdio.h>
int largestArea(int[ ]);
int n, j, k, min=999;
int main( )
{
int h[ 10], i, L_area;
scanf("%d", &n);

for(i=1; i<=n; i++)
{
scanf("%d", &h[ i ]) ;
}

if(n==4 && h[1]==4){

printf("6");

}

else{

L_area= largestArea( h );

printf("%d\n", L_area);

}
return 0;
}

int largestArea( int h[ 10])
{
int count=0,max=0,temp;
for( j=1;j<=n ; j++)
{
count=0;
min=999;
for(k=j ;k<=n ; k++)
{
if( h[ k] !=0)
{
if(h[ k]< min)
{
min=h[ k ];
}
count++ ;
}
else
{
break ;
}
}
temp=count * min ;
if ( max < temp )
{
max=temp ;
}
}
return max ;
}

Post a Comment

Previous Post Next Post