Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12 may assignment #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Laxman singh/12may/12Q1.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<stdio.h>
main()
{
int arr[20],size,i,n,f=0;
printf("enter the size of the array:");
scanf("%d",&size);
printf("enter the elements of array:");
for (i=0;i<size;i++)
{
scanf("%d",&arr[i]);
}
printf("enter the element to be searched:");
scanf("%d",&n); //n is the element which we need to find
for(i=0;i<size;i++)
{
if(arr[i]==n)
{
f=1;
break;
}
}
if(f==1)
{
printf("element found at position %d",i+1);
}
else
{
printf("element not in array");
}
getch();
}
38 changes: 38 additions & 0 deletions Laxman singh/12may/12Q2.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include<stdio.h>
main()
{
int arr[20],i,j,k,size;
clrscr();
printf("enter the size of the array:");
scanf("%d",&size);
printf("enter the elements for array now :");

for(i=0;i<size;i++)
{
scanf("%d",&arr[i]);
}

for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if(arr[i]==arr[j])
{
for(k=j;k<size;k++)
{
arr[k]=arr[k+1];
}
size--;
j--;
}
}
}

printf("array elements after deleting duplicates :");

for(i=0;i<size;i++)
{
printf("%d",arr[i]);
}
getch();
}
21 changes: 21 additions & 0 deletions Laxman singh/12may/12Q3.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<stdio.h>
main()
{
int a[10],n,i; clrscr();
printf("enter the number to convert:");
scanf("%d",&n);

for(i=0;n>0;i++)
{
a[i]=n%2;
n=n/2;

}

printf("\n binary of given number is=");
for (i=i-1;i>=0;i--)
{
printf("%d",a[i]);
}
getch();
}
24 changes: 24 additions & 0 deletions Laxman singh/12may/12Q4.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>
main()
{
char s[100],s1[100];
int i,n,c=0;
printf("enter the string :");
gets(s);
n=strlen(s);
for(i=0;i<n/2;i++)
{
if(s[i]==s[n-i-1])

c++;

}

if(c==i)
printf("string is palindrome");
else
printf("string is not palindrome");

getch();

}
20 changes: 20 additions & 0 deletions Laxman singh/12may/12Q5.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<stdio.h>
main()
{
char s1[100],s2[100],i;

printf("enter string s1:");

fgets(s1,sizeof(s1),stdin);

for(i=0;s1[i]!='\0';++i)
{
s2[i]=s1[i];
}
s2[i]='\0';

printf("string s2: %s",s2);

getch();

}
Binary file added Laxman singh/12may/12q1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Laxman singh/12may/12q2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Laxman singh/12may/12q3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Laxman singh/12may/12q4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Laxman singh/12may/12q5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.