Skip to content
Snippets Groups Projects
Commit a1154875 authored by Mohamed Yasar arafath K M's avatar Mohamed Yasar arafath K M :speech_balloon:
Browse files

initial commit

parent cdbd9f68
No related branches found
No related tags found
No related merge requests found
username password
mohamed1 123yas
yasar89 like123
zero notnot
\ No newline at end of file
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct array_char
{
char user[10];
char password[10];
} store[4];
int user_check();
int main()
{
FILE *fp = fopen("file.txt","r");
char ch,inp[10],pass[10];
int i;
while (fp!=NULL)
{
ch = fgetc(fp);
if (ch!=EOF)
{
printf("%c",ch);
}
else
break;
}
fseek(fp,SEEK_SET,0);
for (i = 0; i < 4; i++)
{
fscanf(fp,"%s %s",store[i].user,store[i].password);
}
user_check(store);
fclose(fp);
}
int user_check(struct array_char *store)
{
int i,count=0;
char user[10],pass[10];
printf("\nEnter a username :");
scanf("%s",user);
for (i = 1; i < 4; i++)
{
if (!(strcmp(user,store[i].user)))
{
printf("\nUser has registered");
printf("\nEnter the password :");
scanf("%s",pass);
if (!(strcmp(pass,store[i].password)))
{
printf("\nLogin successfull");
}
else
printf("\nPassword doesn't match");
break;
}
else
{
count+=1;
if (count>3)
{
printf("\nUser did not register");
}
}
}
}
#include<stdio.h>
#include<string.h>
struct data
{
int register_no;
char name[10];
char department[10];
float avg;
}save[5];
int main()
{
int i;
FILE *fp = fopen("filetemplate.txt","r");
for (i = 0; i < 5; i++)
{
fscanf(fp,"%d %s %s %lf",save[i].register_no,save[i].name,save[i].department,save[i].avg);
}
for (i = 0; i < 5; i++)
{
printf("%s\n",save[i].name);
}
return 0;
}
Noofrecords 4
1001 raj CSE 76.5
1002 raja IT 80.2
1003 kumar CSE 90.2
1004 siva IT 65.8
split.c 0 → 100644
#include<stdio.h>
#include<string.h>
int main()
{
int arr[30],i=0,j=0;
char opt[3]="yes";
while (!(strcmp("yes",opt)))
{
printf("Enter a element :");
scanf("%d",&arr[i]);
printf("Do you wish to continue :");
scanf("%s",opt);
i++;
}
printf("\n");
int size=i;
if (size%2==0 && size > 1)
{
int list1[15],list2[15];
for (i=0; i < size/2; i++)
list1[i]=arr[i];
for (j=0,i = i; i < size/2;i++)
{
list2[j]=arr[i];
j++;
}
for (i = 0; i < size/2; i++)
printf("%d ",list1[i]);
printf("\n");
for (i = size/2; i < size; i++)
printf("%d ",list2[i]);
printf("\n");
}
else if (size%2==1 && size > 1)
{
int list1[10],list2[10],list3[10];
if (size%3==0)
{
int div = size/3;
for (i = 0; i < size/3; i++)
list1[i]=arr[i];
for ( j = 0; j < size/3; j++,i++)
list2[j] = arr[i];
for (j = 0; j < size/3; j++,i++)
list3[j]=arr[i];
printf("\nlist 1 \n");
for (i = 0; i < div; i++)
printf("%d ",list1[i]);
printf("\nList 2\n");
for (i = 0; i < div; i++)
printf("%d ",list2[i]);
printf("\nList 3\n");
for (i = 0; i < div; i++)
printf("%d ",list3[i]);
}
else
{
for (i = 0; i < size/2; i++)
list1[i]=arr[i];
for (j = 0; j < size/2; j++)
{
list2[j]=arr[i];
i++;
}
for (j = 0; j < size-((size/2)*2); j++)
{
list3[j]=arr[i];
i++;
}
printf("\nlist 1 \n");
for (i = 0; i < size/2; i++)
printf("%d ",list1[i]);
printf("\nList 2\n");
for (i = 0; i < size/2; i++)
printf("%d ",list2[i]);
printf("\nList 3\n");
for (i = 0; i < size-((size/2)*2); i++)
printf("%d ",list3[i]);
}
}
else
printf("\nelement must greater than 1\n");
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment