Friday, 29 June 2018
Thursday, 28 June 2018
second largest of array
#include<stdio.h>
int main()
{
int a[100],n,i,max,max2;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=max2=a[0];
for(i=0;i<n;i++)
{
if(a[i]>max)
{
max2=max;
max=a[i];
}
else if(max2<a[i])
{
max2=a[i];
}
}
printf("%d",max2);
return 0;
}
int main()
{
int a[100],n,i,max,max2;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=max2=a[0];
for(i=0;i<n;i++)
{
if(a[i]>max)
{
max2=max;
max=a[i];
}
else if(max2<a[i])
{
max2=a[i];
}
}
printf("%d",max2);
return 0;
}
double diognal
#include<stdio.h>
int main()
{
int i,j,k,n;
printf("enter the number");
scanf("%d",&n);
int a=1,b=20,c=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("%d ",a);
a++;
}
for(k=i+1;k<c;k++)
{
printf("%d ",b);
b--;
}
printf("\n");
}
return 0;
}
output:
enter the number4
1 20 19 18 17
2 3 16 15 14
4 5 6 13 12
7 8 9 10 11
int main()
{
int i,j,k,n;
printf("enter the number");
scanf("%d",&n);
int a=1,b=20,c=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("%d ",a);
a++;
}
for(k=i+1;k<c;k++)
{
printf("%d ",b);
b--;
}
printf("\n");
}
return 0;
}
output:
enter the number4
1 20 19 18 17
2 3 16 15 14
4 5 6 13 12
7 8 9 10 11
number pattern
#include<stdio.h>
int main()
{
int i,j,n;
printf("enter the number");
scanf("%d",&n);
int l=n;
for(i=0;i<n;i++)
{
int x=n;
for(j=l;j>0;j--)
{
printf("%d",x);
x--;
}
l--;
printf("\n");
}
l=2;
for(i=0;i<n-1;i++)
{
int x=n;
for(j=1;j<=l;j++)
{
printf("%d",x);
x--;
}
l++;
printf("\n");
}
return 0;
}
output:
enter the number4
4321
432
43
4
43
432
4321
int main()
{
int i,j,n;
printf("enter the number");
scanf("%d",&n);
int l=n;
for(i=0;i<n;i++)
{
int x=n;
for(j=l;j>0;j--)
{
printf("%d",x);
x--;
}
l--;
printf("\n");
}
l=2;
for(i=0;i<n-1;i++)
{
int x=n;
for(j=1;j<=l;j++)
{
printf("%d",x);
x--;
}
l++;
printf("\n");
}
return 0;
}
output:
enter the number4
4321
432
43
4
43
432
4321
Anagrams
#include<stdio.h>
#include<string.h>
int main()
{
char s1[20],s2[20];
printf("enter string1");
scanf("%s",s1);
printf("enter string2");
scanf("%s",s2);
int f1[26]={0},f2[26]={0};
int i;
int l1=strlen(s1),l2=strlen(s2),flag=0;
for(i=0;i<l1;i++)
{
int a=s1[i]-'a';
f1[a]++;
}
for(i=0;i<l2;i++)
{
int a=s2[i]-'a';
f2[a]++;
}
for(i=0;i<26;i++)
{
if(f1[i]!=f2[i])
{
flag=1;
break;
}
else
flag=0;
}
if(flag==0)
printf("anagrams");
else
printf("not anagrams");
return 0;
}
#include<string.h>
int main()
{
char s1[20],s2[20];
printf("enter string1");
scanf("%s",s1);
printf("enter string2");
scanf("%s",s2);
int f1[26]={0},f2[26]={0};
int i;
int l1=strlen(s1),l2=strlen(s2),flag=0;
for(i=0;i<l1;i++)
{
int a=s1[i]-'a';
f1[a]++;
}
for(i=0;i<l2;i++)
{
int a=s2[i]-'a';
f2[a]++;
}
for(i=0;i<26;i++)
{
if(f1[i]!=f2[i])
{
flag=1;
break;
}
else
flag=0;
}
if(flag==0)
printf("anagrams");
else
printf("not anagrams");
return 0;
}
Subscribe to:
Posts (Atom)
ASP.NET Core: How to implement Azure Active Directory (AAD) Authentication in ASP.NET Core
In this tutorial, we will implement security for ASP.NET Core Application using Azure Active Directory (AAD). In this tutorial, I will co...
-
////////// HANDS-ON 1 ///////////////// 1) az network vnet create -g resourceaddressgiveninkatacoda -n myvnet 2) az network vnet delete...
-
Operations Rio quiz 1.Discipline in execution+pursuit of excellnce+customer experience 2.consistent+proactive risk management,discipli...
-
Merge handson Step1 git branch git checkout feature1 Step2 git checkout master git merge feature1 Step3 git checkout feature2 gi...