0% found this document useful (0 votes)
3 views5 pages

23bcs216 1homework

Uploaded by

ishumvs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

23bcs216 1homework

Uploaded by

ishumvs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.#include <stdio.

h>
int main(){
int m,n;
scanf("%d", &m);
scanf("%d", &n);
int a[m][n];
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
scanf("%d", &a[i][j]);
}
} int x=0,y=0;
for(int i=0; i<m; i++){
x=0;
for(int j=0; j<n; j++){
if(a[i][j]>x){
x=a[i][j];
}
}
printf("%d\n", x);
}
for(int i=0; i<n; i++){
y=0;
for(int j=0; j<m; j++){
if(a[j][i]>y){
y=a[j][i];
}
}
printf("%d\n", y);
}
return 0;
}
2.#include <stdio.h>
#include<math.h>
int main(){
int n;
scanf("%d", &n);
int x=n,sum=0;
while(n>0){
int y=n%10;
int z=pow(y,3);
sum+=z;
n/=10;
}
printf("%d", sum);
if(sum==x)
printf("the given number is armstrong number");
else
printf("Not an armstrong number");
return 0;
}
3.#include <stdio.h>
int main(){
int m,n;
scanf("%d", &m);
scanf("%d", &n);
int a[m][n];
int b[m];
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
scanf("%d", &a[i][j]);
}
}
int q;
scanf("%d", &q);
if(q==2){
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
if(i==0 || i==m-1){
printf("%u\n", &a[i][j] );
}
}
}
}
if(q==3){
for(int j=0;j<n;j++)
{
int s,max=0;
for(int i=0;i<m;i++)
{
int count=0;
for(int k=i+1;k<m;k++)
{
if(a[i][j]==a[k][j])
count++;
}
if(max<count)
{
max=count;
s=a[i][j];
}

}
printf("Mode of column %d is %d \n",j,s);
}
printf("\n");

}
if(q==4){
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
if(i==j){
b[i]=a[i][j];
}
}
}
for(int i=0; i<m; i++){
for(int j=i+1; j<m; j++){
if(b[i]>b[j]){
int temp=b[i];
b[i]=b[j];
b[j]=temp;
}
}
}
int k;
scanf("%d", &k);
printf("%d", b[k-1]);
}

if(q==5){
int *ptr=&a[0][0];
for(int i=0;i<m*n; i++){
printf("%d\n", *ptr);
ptr++;
}
}
return 0;
}
4.#include<stdio.h>
#include <ctype.h>
int main()
{
int n;
printf("Enter the array size\n");
scanf("%d",&n);
char p[n][50];
int arr[n];
for(int i=0;i<n;i++)
{
printf("Enter the string size\n");
scanf("%d",&arr[i]);
for(int j=0;j<arr[i];j++)
{

scanf(" %c",&p[i][j]);

}
int q=1;
while(q!=0)
{
int c;
printf("Type an option to be performed\n");
scanf("%d",&c);
q=c;
if(q==2)
{
for(int i=0;i<n;i++)
{
int count=0;
for(int j=0;j<arr[i];j++)
if(p[i][j]!='a'&&p[i][j]!='e'&&p[i][j]!='i'&&p[i][j]!='o'&&p[i][j]!='u')
{
count++;
}
printf("Consonants in string %d are %d\n",i,count);

}
printf("\n");
}
else if(q==3)
{
for(int i=0;i<n;i++)
{
for(int j=arr[i];j>=0;j--)
{
printf("%c",p[i][j]);
}
printf("\n");

}
else if(q==4)
{
for(int i=0;i<n;i++)
{
int count=0;
for(int j=0;j<arr[i];j++)
if((p[i][j]=='a'||p[i][j]=='e'||p[i][j]=='i'||p[i][j]=='o'||p[i][j]=='u')&&p[i][j]!=' ')
{
p[i][j]=toupper(p[i][j]);
}
printf("%s\n",p[i]);

}
printf("\n");
}
else if(q==5)
{
for(int i=0;i<n;i++)
{

printf("%p\n",&p[i][0]);

}
}
}
return 0;
}

You might also like