Write a Modular C Programming code for Finding the Block-chain compare, search, string
Blockchain is the new technology in computer science, where it is used to store the
‘n’ transaction details of users. Shivam is very much interested in implementing
blockchain kind of technology using C programming.Transaction details contains:
Transaction_ID, sender name, receiver name, amount, time. Please help Shivam to
implement the above problem and perform the below operations.
i) Display the transaction details of particular Transaction_ID.
ii) Display the transaction details of particular user.
CODE:
#include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct tech { char s_name[10],r_name[10]; int transaction_ID,amount,time; }T; void read_details(T *t,int n); void display_details(T *t,int n); T trans_ID(T *t,int n); void particular_user(T *t,int n); int main() { T blockchain[10]; T *t; t=&blockchain; int n; printf("Enter total number of users present\n"); scanf("%d",&n); read_details(t,n); display_details(t,n); trans_ID(t,n); particular_user(t,n); return 0; } void read_details(T *t,int n) { int i; printf("Enter the sender name reciever name transaction ID amount time\n"); for(i=0;i<n;i++) { scanf("%s %s %d %d %d",t->s_name,t->r_name,&t->transaction_ID,&t->amount,&t->time); t++; } } void display_details(T *t,int n) { int i; printf("Sender name receiver name transaction ID amount time\n"); for(i=0;i<n;i++) { printf("%s %s %d %d %d\n",t->s_name,t->r_name,t->transaction_ID,t->amount,t->time); t++; } } T trans_ID(T *t,int n) { int i; int transa; printf("Enter the transaction ID\n"); scanf("%d",&transa); for(i=0;i<n;i++) { if((t->transaction_ID) == transa) { printf("The details of the transaction ID are %s %s %d %d %d\n",t->s_name,t->r_name,t->transaction_ID,t->amount,t->time); } t++; } } void particular_user(T *t,int n) { int i; char nam; printf("Enter the sender user name\n"); scanf("%s",nam); for(i=0;i<n;i++) { if(strcmp(t->s_name,nam)==0) { printf("The user details are %s %s %s %d %d\n",t->s_name,t->r_name,t->transaction_ID,t->amount,t->time); } t++; } }
OUTPUT
Enter total number of users present 2 Enter the sender name reciever name transaction ID amount time elon mark 1002 300 5 bitcoin davin 102 500 3 Sender name receiver name transaction ID amount time elon mark 1002 300 5 bitcoin davin 102 500 3 Enter the transaction ID 102 The details of the transaction ID are bitcoin davin 102 500 3 Process returned -1073741819 (0xC0000005) execution time : 43.573 s Press any key to continue.
© Credits
Sai Rohit Verma (1)
'P' div
Department of Computer Science
( ) — Number of Contributions!
Refer : C Programming HackerRank all solutions for Loops | Arrays | strings
Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:
Top 100+ C Programming codes – KLE Technological University