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

Add files via upload #126

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
37 changes: 37 additions & 0 deletions charvi mathur assignment 2/Q1. search element in array.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
int main()
{
int arr[100];
int size, i, toSearch, found;
printf("************ Search A Given Value ! ************\n");
printf("Enter size of array: ");
scanf("%d", &size);
printf("Enter elements in array: ");

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

printf("Enter element to search: ");
scanf("%d", &toSearch);
found = 0;

for(i=0; i<size; i++)
{
if(arr[i] == toSearch)
{
found = 1;
break;
}
}
if(found == 1)
{
printf("%d is found at position %d", toSearch, i + 1);
}
else
{
printf("%d is not found in the array", toSearch);
}
return 0;
}
Binary file added charvi mathur assignment 2/Q1_OUTPUT.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions charvi mathur assignment 2/Q2. Remove Duplicate value.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include<stdio.h>
void main()
{
int a[20], i, j, k, n;

printf("Enter array size: ");
scanf("%d", &n);
printf("Enter %d array element: ", n);

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

printf("After Duplicate element remove : ");
for(i = 0; i < n; i++)
{
for(j = i+1; j < n; )
{
if(a[j] == a[i])
{
for(k = j; k < n; k++)
{
a[k] = a[k+1];
}
n--;
}
else
{
j++;
}
}
}

for(i = 0; i < n; i++)
{
printf("%d ", a[i]);
}

}
Binary file added charvi mathur assignment 2/Q2_OUTPUT.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions charvi mathur assignment 2/Q3. Number to binary convert.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
int main()
{
int n =10;
int binaryNum[32];
int i = 0;
int result;
printf("Number is : %d",n);
printf("\nNumber to Binary Convert : ");
while (n > 0)
{
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--)
{
result = binaryNum[j];
printf("%d ",result);
}
return 0;
}
Binary file added charvi mathur assignment 2/Q3_OUTPUT.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions charvi mathur assignment 2/Q4. String is Palindrome or not.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>
#include <string.h>

int main(){
char string1[20];
int i, length;
int flag = 0;

printf("Enter a string:");
scanf("%s", string1);
length = strlen(string1);

for(i=0;i < length ;i++){
if(string1[i] != string1[length-i-1]){
flag = 1;
break;
}
}
if (flag) {
printf("%s is not a palindrome", string1);
}
else {
printf("%s is a palindrome", string1);
}
return 0;
}
Binary file added charvi mathur assignment 2/Q4_OUTPUT.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
int main()
{
char s1[]="HELLO!", s2[100], i;
printf("string s1 : %s\n", s1);

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

s2[i] = '\0';
printf("String s1 Copy to String s2 : %s", s2);

return 0;
}
Binary file added charvi mathur assignment 2/Q5_OUTPUT.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.